<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@page import="com.yaodian100.mall.member.util.UserData"%>
<%@page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>    
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@taglib prefix="pu" uri="/WEB-INF/tld/pageutil.tld" %>

<%@page import="java.util.Date"%>
<%@page import="org.apache.commons.lang.time.DateUtils"%>
<c-rt:set var="frontContextPath" value='<%=ServerValue.getFrontContextPath()%>'/>
<c-rt:set var="discountType" value='<%=ServerValue.getDiscountType()%>'/>
<c-rt:set var="useCreditcard" value='<%=ServerValue.getUseCreditcard()%>'/>
<c-rt:set var="useCreditcardPeriod" value='<%=ServerValue.getUseCreditcardPeriod()%>'/>
<style>
.promo-popup{padding:10px;*padding:10px 0 10px 8px; color:#666;line-height:1.4em; }
.promo-popup h2,.promo-popup h3{font-size:15px;color:#d12e6f; margin-bottom:.8em;}
.promo-popup h3{color:#666;}
.promo-popup p{margin:.5em 0;}
.promo-popup .d-line{background:url(/images/link_dote.gif) repeat-x scroll 0 50%; padding:1px 0;}
.promo-popup ol,.promo-popup ul{margin-bottom:1em;margin-left:2em;}
.promo-popup li{list-style:decimal;}
</style>
<Style>
li.w-1of1{overflow:hidden}
</style>
<!-- 地址选单 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.alphanumeric.js"></script>
<script type="text/javascript">
     <%--售价(可有小数点)--%>
     jQuery.fn.ydPrice = function() {
         return this.each(function() {
          $(this).keyup(function(){
                   $(this).val($(this).val().replace(/[^\d\.}]/g,''));
              });
         });
     };
     <%--只能输入正整数或0--%>
     jQuery.fn.onlyInteger = function() {
         return this.each(function() {
          $(this).keyup(function(){
                   $(this).val($(this).val().replace(/[^0-9]/g,''));
              });
         });
     };  
     $().ready(function() { 
          $("#chang_image").click(function(){
               $("#iv").attr("src","<%=ServerValue.getFrontContextPath()%>/servlet/imageValid.jpg?"+Math.random());
          });
          $("#showProdVolume").click(function(){
              $("#arriveplace").show();
          });
          $("#prodVolumeClose").click(function(){
              $("#arriveplace").hide();
          });
                  
          <%--赠品数量不足时--%>
          $("#chkPinvyDialog").dialog({
              bgiframe: true,
              autoOpen: false,
              height: 200,
              width:400,
              modal: true
          });      

          <%--主商品数量不足时--%>
          $("#chkProdInvDialog").dialog({
              bgiframe: true,
              autoOpen: false,
              height: 200,
              width:400,
              modal: true
          });      
          if ( "${prtFlag}" == "" ){
              if("${actionResult}" != "" && "${actionResult}"!='OK'){<%--主商品數量檢查--%>
                   //alertDialog("库存不足",result,"",400,200);
                   if("${actionResult}".indexOf('赠品 ')>0){
                        $("#chkPinvyDialog > p").eq(0).html("${actionResult}");
                        $('#chkPinvyDialog').dialog('destroy');
                        $('#chkPinvyDialog').dialog({
                             closeOnEscape: false,
                             open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); },
                             bgiframe: true,
                             width:380,
                             modal: true
                        });
                   }else{
                        //alert(result);
                        $("#chkProdInvDialog > p").eq(0).html("${actionResult}");
                        $('#chkProdInvDialog').dialog('destroy');
                        $('#chkProdInvDialog').dialog({
                             closeOnEscape: false,
                             open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); },
                             bgiframe: true,
                             width:380,
                             modal: true
                        });
                        //alertDialog("库存不足",result,"",400,200);
                   }
              }
          }
          <%--商品数量不足-回商品页--%>
          $('#presentNotEnough').click(function(){
               location.href='<%=ServerValue.getFrontContextPath()%>/product/product.do?productId=<%=request.getParameter("itemNo")%>&z=<%=request.getParameter("categoryPath")%>';
              return false;
          });
          <%--商品数量不足-回商品页--%>
          $('#mainProdNotEnough').click(function(){
               location.href='<%=ServerValue.getFrontContextPath()%>/product/product.do?productId=<%=request.getParameter("itemNo")%>&z=<%=request.getParameter("categoryPath")%>';
              return false;
          });               
          $("#orderCartDetailOpen").hide();
       $("#orderCartDetailClose").show(); 
       $("#contactNameTip").hide();
          $("#addrTip").hide();
          $("#telTip").hide();
          $("#provinceTip").hide();   
          $("#mailTip").hide();  
         
          $("#paytype30").attr("disabled",true);
          $("#paytypeCash").attr("disabled",true);
          $("#paytypePos").attr("disabled",true);
          if($("#contactName").val()==''){
              $("#contactName").val("(请输入收货人姓名)").css("color","#aaa")};

          $("#contactName").focus(function(){
              if($("#contactName").val()=='(请输入收货人姓名)'){
               $("#contactName").val("").css("color","#000")};
          }).blur(function(){
              if($("#contactName").val()==''){
              $("#contactName").val("(请输入收货人姓名)").css("color","#aaa")};
          });

          if($("#addr").val()==''){
              $("#addr").val("(输入街道地址，例如：和平路12巷52号)").css("color","#aaa")};

          $("#addr").focus(function(){
              if($("#addr").val()=='(输入街道地址，例如：和平路12巷52号)'){
              $("#addr").val("").css("color","#000")};
          }).blur(function(){
              if($("#addr").val()==''){
              $("#addr").val("(输入街道地址，例如：和平路12巷52号)").css("color","#aaa")};
          });


          if($("#memo").val()==''){
              $("#memo").val("(非必填项目，可在此说明对商品的特殊需求，我们虽無法保證，但将努力配合您的需求。)").css("color","#aaa")};

          $("#memo").focus(function(){
              if($("#memo").val()=='(非必填项目，可在此说明对商品的特殊需求，我们虽無法保證，但将努力配合您的需求。)'){
              $("#memo").val("").css("color","#000")};
          }).blur(function(){
              if($("#memo").val()==''){
              $("#memo").val("(非必填项目，可在此说明对商品的特殊需求，我们虽無法保證，但将努力配合您的需求。)").css("color","#aaa")};
          });      

          <%--當客人無帳戶餘額,不可以勾選用我的帳戶餘額--%>
          if(parseFloat($("#myVirtualBalance").text())==0){
              $("#subVrtlBlnc").attr("disabled",true);
              $("#chkVrtBlnc").attr('disabled',true);
              $("#paytype40").attr("disabled",true);
          }

          <%--當客人無礼品卡,不可以勾選用我的礼品卡--%>
          if(parseFloat($("#myGiftCardBalance").text())==0){
              $("#subGiftCard").attr("disabled",true);
              $("#chkGiftCard").attr('disabled',true);
              $("#paytype40").attr("disabled",true);
          }        
         
          <%--商品重量計算--%>
          $("#showweight").click(function(){
              if($("#addCmpPd").val()!=""){
                   var cmpPordId=$("#addCmpPd").val().split(",")[0];
                   openDialog("商品重量計算",$("#showWeightDialog").load("<%=ServerValue.getFrontContextPath()%>/shopping/showWeight.do?cartId=${cartId}&cmpPordId="+cmpPordId),700,500);
              }else{
                   openDialog("商品重量計算",$("#showWeightDialog").load("<%=ServerValue.getFrontContextPath()%>/shopping/showWeight.do?cartId=${cartId}"),700,500);
              }            
          });
          <%--从收货地址簿选取--%>
          $("#myAddBook").click(function(){
              openDialog("从收货地址簿选取",$("#myAddBookDialog").load("<%=ServerValue.getFrontContextPath()%>/shopping/orderInfo/loadMyAddBook.do?id=${cartOrders.cartId}"),700,'auto');             
          });
          <%--选择折扣礼券--%>
          $("#chkCoupon").click(function(){
              $("#chkBonus").attr('checked', false);
              $("#editBonus").val('0.0');
              $("#editOffsetBonus").text('0');
              $("#offset").text("0.0");
              $("#offsetBonus").text("0");
              initPaytype();
              initWallet();
              initGiftCard();
              if (this.checked){
                   var ss = Math.ceil(Math.random()*999999999999999);
                   <c-rt:if test="${isBuyNow}">
                   <c-rt:set scope="request" var="categoryPath">
                   ${cartOrders.cartOrderProducts[0].categoryPath}
                   </c-rt:set>
                   <%
                        String categoryPath=(String)request.getAttribute("categoryPath");
                        String categorySplit[]=categoryPath.split("/");
                        if(categorySplit!=null){
                             String categoryId=categorySplit[categorySplit.length-1];
                             request.setAttribute("categoryId", categoryId);
                        }
                   %>
                   openDialog("选择折扣礼券",$("#myCouponDialog").load("<%=ServerValue.getFrontContextPath()%>/shopping/orderInfo/loadMyCoupon.do?ss="+ss+"&isBuyNow=Y_${cartOrders.cartOrderProducts[0].prodId}_xx_${categoryId}"),700,'auto');
                   </c-rt:if>
                   <c-rt:if test="${!isBuyNow}">
                   openDialog("选择折扣礼券",$("#myCouponDialog").load("<%=ServerValue.getFrontContextPath()%>/shopping/orderInfo/loadMyCoupon.do?ss="+ss),700,'auto');
                   </c-rt:if>
                   ProcessCalcuTotal();
                   $("#rechkCoupon").show();
              }else{
                   $("#editCoupon").val('0.0');
                   $("#showCpCode").val("");
                   $("#allpaymsg").hide();
                   $("input[id^='paytype']").each(function(i){
                        $(this).attr("disabled", false);
                        $(this).attr("checked", false);
                   });
                   //processBonus(0);
                   ProcessCalcuTotal();
                   $("#rechkCoupon").hide();
              }
             
          }); 
         
          <%--重新选择礼券--%>
          $("#rechkCoupon").click(function(){
              openDialog("选择折扣礼券","",700,'auto');
          });

          <%--耀点100货到付款支援区域--%>
          $("a.cssPayArrive").click(function(){
              openDialog("耀点100货到付款支援区域",$("#divPayArrive").load("/pages/CART/step02_pay_arrive.html"),700,700);            
          });

          <%--耀点100运费计算标准--%>
          $("#payPortage").click(function(){
              openDialog("耀点100运费计算标准",$("#divPayPortage").load("/pages/CART/step02_pay_portage.html"),700,360);          
          });

          <%--选择購物金--%>     
          $("#chkBonus").click(function(){
              <c-rt:if test="${discountType eq 'single'}">
              $("#chkCoupon").attr("checked",false);
              $("#editCoupon").val(0.0);
              $("#showCpCode").val("");
              ProcessCalcuTotal();
              </c-rt:if>
              initWallet();
              initGiftCard();
              if (this.checked){
                   processBonus($("#editCoupon").val());
                   ProcessCalcuTotal();
                   var iCanUse=parseInt($("#canUse").val(),10);            
                   var iOffset=parseInt($("#offset").text(),10);
                   if(iCanUse-iOffset<0){
                        $("#editBonus").val(iCanUse.toFixed(1));
                        $("#editOffsetBonus").text(iCanUse*parseFloat("${bonusCampaign.offsetRate}"));
                        $("#offset").text(iCanUse.toFixed(1));
                        $("#offsetBonus").text(iCanUse*parseFloat("${bonusCampaign.offsetRate}"));
                        ProcessCalcuTotal();        
                   }
              }else{
                   $("#editBonus").val('0.0');
                   $("#editOffsetBonus").text('0');
                   $("#offset").text("0.0");
                   $("#offsetBonus").text("0");
                   ProcessCalcuTotal();
              }
          });      

          $("#orderCartToggleCloseName").click(function () {
                $("#orderCartDetailClose").hide();
                $("#orderCartDetailOpen").show();             
          }); 
          $("#orderCartToggleOpenName").click(function () {             
                $("#orderCartDetailOpen").hide();
                $("#orderCartDetailClose").show();            
          }); 
         
          $("#contactName").alpha();       
          $("#zipCode").onlyInteger();
          $("#mobile").onlyInteger();
          $("#areaCode").onlyInteger();
          $("#phone").onlyInteger();
          $("#extension").onlyInteger();
          $("#subVrtlBlnc").ydPrice();
          $("#subGiftCard").ydPrice();

          if($("#addCmpPd").val()!=""){
              var addCmpPrdArray=$("#addCmpPd").val().split(',');
              $("#tCampP").append("<tr id='trCampP'>"
                        + "<td colspan='5' align='left' class='table-in'>"
                        + "<table border='0'>"
                        +    "<tr>"
                        + "<td width='500'><p>"+addCmpPrdArray[3]+"</p></td>"
                        + "<td width='50'><span class='type-5'>满额购</span></td>"
                        + "<td width='70'>&nbsp;</td>"
                        + "<td width='85' class='txt-price'>￥" + parseFloat(addCmpPrdArray[2]).toFixed(1) + "</td>"
                        + "<td width='50'>1</td>"
                        + "<input type='hidden' id='editAmount_x'  value='" + parseFloat(addCmpPrdArray[2]).toFixed(1)+"'/>"
                        + "</tr>"
                        + "</table>"
                        + "</td>"
                        + "<td align='left' class='txt-price'>￥" + parseFloat(addCmpPrdArray[2]).toFixed(1) + "</td>"
                        + "</tr>");
          }
          <%--帳戶餘額--%>
          $("#subVrtlBlnc").blur(function() {
              if($("#subVrtlBlnc").val()==""){
                   $("#subVrtlBlnc2").val("0.0");
              }else{
                   $("#subVrtlBlnc2").val(parseFloat($("#subVrtlBlnc").val()).toFixed(1));
              }
              ProcessCalcuTotal();
          });
          <%--禮品卡餘額--%>
          $("#subGiftCard").blur(function() {
              if($("#subGiftCard").val()==""){
                   $("#subGiftCard2").val("0.0");
              }else{
                   $("#subGiftCard2").val(parseFloat($("#subGiftCard").val()).toFixed(1));
              }
              ProcessCalcuTotal();
          });      
    
          $.getJSON("<%=ServerValue.getFrontContextPath()%>/shopping/orderInfo/findLastAddBook.do?type=json",{type:'cart',id:'${cartOrders.cartId}'}
                   ,function(addBookDataJson){
                   if(addBookDataJson!=null){
                        $("#contactName").val(addBookDataJson.contactName).css("color","#000");
                        $("#addr").val(addBookDataJson.addr).css("color","#000");
                        $("#zipCode").val(addBookDataJson.zipCode);                                 
                        if(addBookDataJson.mobile==null){
                             $("#mobile").val("");
                        }else{
                             $("#mobile").val(trim(addBookDataJson.mobile));
                        }
                        if(addBookDataJson.areaCode==null){
                             $("#areaCode").val("");
                        }else{
                             $("#areaCode").val(addBookDataJson.areaCode);
                        }
                        if(addBookDataJson.phone==null){
                             $("#phone").val("");
                        }else{
                             $("#phone").val(trim(addBookDataJson.phone));
                        }
                        if(addBookDataJson.extension==null){
                             $("#extension").val("");
                        }else{
                             $("#extension").val(addBookDataJson.extension);
                        }
                        $("#province").children().each(function(index){
                             if (trim($(this).text()) == trim(addBookDataJson.province)){
                                  //$(this).attr("selected","selected");
                                  $("#province")[0].selectedIndex = index ;
                                  queryProvince2(addBookDataJson.city,addBookDataJson.district);
                             }
                        });
                        <%--判断是否可货到付款--%>
                        var tmpCity=$("#city").find('option:selected').val();
                        var tmpDistrict=$("#district").find('option:selected').text();
                        if(tmpDistrict.substring(0,1)=='※' && "${canUseCod}" == "true"){
                             $("#paytype30").attr("disabled",false);
                             $("#paytypeCash").attr("disabled",false);
                             $("#paytypePos").attr("disabled",false);
                             $("#displayPOS").show();
                        }else{
                             $("#paytype30").attr("disabled",true);
                             $("#paytype30").attr("checked",false);
    
                             $("#paytypeCash").attr("disabled",true);
                             $("#paytypeCash").attr("checked",false);
    
                             $("#paytypePos").attr("disabled",true);
                             $("#paytypePos").attr("checked",false);
                             $("#displayPOS").hide();
                        }                      
                        isPos();          
                        <%--计算运费--%>
                        var tmpProvince=$("#province").find('option:selected').val();
                        var tmpIsBuyNow=$("#isBuyNow").val();
                        var tmpFinalMustPay=$("#editTotalAmount").val();
                        var addCmpPd=$("#addCmpPd").val();
                        var tmpChkInveny=$("#chkInveny").val();<%--立即購買--%>
                        var buyNowCartId=$("#buyNowCartId").val();
                        caleShipFare(tmpProvince,tmpIsBuyNow,tmpFinalMustPay,addCmpPd,buyNowCartId);
                   }   
              });
              initAllowSplit();
              <%--付款方式--%>
               $("input[type='radio'][name='paytype']").each(function(){
                   $(this).click(function(){
                        initAllowSplit();
                        var payId = $(this).attr("id");
                        if ( payId == "paytype10" || payId == "paytype20" || payId == "paytype50" || payId == "paytype70" || payId == "paytype80"){//银行转帐、邮局汇款、网上支付、信用卡：一次付清、信用卡：分期
                             if ($("input[id=' + payId + ']").is(":checked") == true){
                                  <%--帳戶餘額--%>
                                  var numChkVrtBlnc=parseInt($("#chkVrtBlnc").val(),10);
                        if(numChkVrtBlnc==0){
                             $("#subVrtlBlnc2").val(0.0);
                                       $("#chkVrtBlnc").val(0.0);
                                       $("#subVrtlBlnc").attr("disabled",false);
                        }else{
                             $("#subVrtlBlnc").attr("disabled",false);
                        }
                        <%--禮品卡--%>
                                  var numChkGiftCard=parseInt($("#chkGiftCard").val(),10);
                        if(numChkGiftCard==0){
                             $("#subGiftCard2").val(0.0);
                                       $("#chkGiftCard").val(0.0);
                                       $("#subGiftCard").attr("disabled",false);
                        }else{
                             $("#subGiftCard").attr("disabled",false);
                        }                      
                             }
                             unCheckPeriod();
                  unCheckPos();
                  checkIfDisableCOD('false');
                        }else if ( payId == "paytype30" ){<%--货到付款--%>
                             if ($('input[id=paytypeCash]').is(":checked") == false && $('input[id=paytypePos]').is(":checked") == false){
                                  $("#paytypeCash").attr("disabled",false);
                                  $("#paytypeCash").attr("checked",true);
                                  serviceSupportMessage("20");
                                  $("#paytype30").val("30");
                             }
                  if ($('input[id=paytype30]').is(":checked") == true){
                       $("#allowSplitY").attr("disabled",true); //cod不允许拆单
                                  $("#allowSplitY").attr("checked",false);
                                  $("#allowSplitN").attr("checked",true);
                    if(trim($("#mobile").val())==""){
                        alertDialog('填手机号码', '选择货到付款必须填手机号码',"",350,120);
                    }
                    <%--帳戶餘額--%>
                    var numChkVrtBlnc=parseInt($("#chkVrtBlnc").val(),10);
                    if(numChkVrtBlnc==0){
                        $("#subVrtlBlnc2").val(0.0);
                                       $("#chkVrtBlnc").val(0.0);
                                       $("#subVrtlBlnc").attr("disabled",false);
                      }else{
                           $("#subVrtlBlnc").attr("disabled",false);
                      }
                    <%--禮品卡--%>
                                  var numChkGiftCard=parseInt($("#chkGiftCard").val(),10);
                        if(numChkGiftCard==0){
                             $("#subGiftCard2").val(0.0);
                                       $("#chkGiftCard").val(0.0);
                                       $("#subGiftCard").attr("disabled",false);
                        }else{
                             $("#subGiftCard").attr("disabled",false);
                        }        
                             }
                  unCheckPeriod();
                  isPos();
                  checkIfDisableCOD('true');
                        }else if ( payId == "paytype40" ){<%--全额由我的帐户余额或礼品卡付清--%>  
                             if ($('input[id=paytype40]').is(":checked") == true){
                                  if ( parseFloat($("#myVirtualBalance").text()) > 0 ){<%--由我的帐户余额付清--%>
                         if(parseFloat($("#finalTotalAmount").val())>=parseFloat($("#myVirtualBalance").text())){
                               $("#subVrtlBlnc").val(parseFloat($("#myVirtualBalance").text()).toFixed(1));
                              $("#subVrtlBlnc2").val(parseFloat($("#myVirtualBalance").text()).toFixed(1));
                        }else{
                              $("#subVrtlBlnc").val(parseFloat($("#finalTotalAmount").val()).toFixed(1));
                              $("#subVrtlBlnc2").val(parseFloat($("#finalTotalAmount").val()).toFixed(1));
                        }
                              $("#chkVrtBlnc").attr("checked",true);
                      
                        if($("#subVrtlBlnc").val()==""){
                            $("#chkVrtBlnc").val(0.0);
                             }else{
                                  $("#chkVrtBlnc").val($("#subVrtlBlnc").val());
                             }
                           $("#subVrtlBlnc").attr("disabled",true);
                                  }
                                  if ( parseFloat($("#myGiftCardBalance").text()) > 0 ){<%--由我的礼品卡付清--%>
                                       if(parseFloat($("#finalTotalAmount").val())>=parseFloat($("#myGiftCardBalance").text())){
                               $("#subGiftCard").val(parseFloat($("#myGiftCardBalance").text()).toFixed(1));
                              $("#subGiftCard2").val(parseFloat($("#myGiftCardBalance").text()).toFixed(1));
                        }else{
                              $("#subGiftCard").val(parseFloat($("#finalTotalAmount").val()).toFixed(1));
                              $("#subGiftCard2").val(parseFloat($("#finalTotalAmount").val()).toFixed(1));
                        }
                              $("#chkGiftCard").attr("checked",true);
                      
                        if($("#subGiftCard").val()==""){
                            $("#chkGiftCard").val(0.0);
                             }else{
                                  $("#chkGiftCard").val($("#subGiftCard").val());
                             }
                           $("#subGiftCard").attr("disabled",true);
                                  }
                             }else{
                                  $("#subVrtlBlnc").val("");
                                  $("#subVrtlBlnc2").val(0.0);
                                  $("#chkVrtBlnc").val(0.0);
                                  $("#subGiftCard").val("");
                                  $("#subGiftCard2").val(0.0);
                                  $("#chkGiftCard").val(0.0); 
                             }
                             unCheckPeriod();
                    checkIfDisableCOD('false');
                        }
                        if ( payId == "paytype10" || payId == "paytype20" || payId == "paytype30" || payId == "paytype40" || payId == "paytype50" || payId == "paytype70" || payId == "paytype80"){
                             if("on"=="<%=ServerValue.getBlockOrderPaymentType()%>"){
                                   if(${member.applySource eq 'nonmember'}){
                                    checkLoginMember("#");
                                   }else{
                                       if($("#ismobileVaild").val()=="false"){
                                        openDialog("手机验证",$("#mobileVaildDialog").load("<%=ServerValue.getFrontContextPath()%>/shopping/orderInfo/loadMobilVaild.do"),500,'auto');
                                    }
                                   }
                             }
                        }
                   });
              });

              $('input[id=paytypeCash]').click(function() {
                   $("#allowSplitY").attr("disabled",true); //cod不允许拆单
                   $("#allowSplitY").attr("checked",false);
                   $("#allowSplitN").attr("checked",true);
                   $("#paytype30").attr("checked",true);
                   $("#paytype30").val("30");
                    checkIfDisableCOD('true');
                    if("on"=="<%=ServerValue.getBlockOrderPaymentType()%>"){
                         if(${member.applySource eq 'nonmember'}){
                         checkLoginMember("#");
                      }else{
                              if($("#ismobileVaild").val()=="false"){
                       openDialog("手机验证",$("#mobileVaildDialog").load("<%=ServerValue.getFrontContextPath()%>/shopping/orderInfo/loadMobilVaild.do"),500,'auto');
                     }else{
                      serviceSupportMessage("20");
                     }
                      }
                    }else{
                         serviceSupportMessage("20");
                    }
              });
              $('input[id=paytypePos]').click(function() {
                   $("#allowSplitY").attr("disabled",true); //cod不允许拆单
                   $("#allowSplitY").attr("checked",false);
                   $("#allowSplitN").attr("checked",true);
                   $("#paytype30").attr("checked",true);
                   $("#paytype30").val("60");
                   checkIfDisableCOD('true');
                   if("on"=="<%=ServerValue.getBlockOrderPaymentType()%>"){
                        if(${member.applySource eq 'nonmember'}){
                             checkLoginMember("#");
                        }else{
                             if($("#ismobileVaild").val()=="false"){
                openDialog("手机验证",$("#mobileVaildDialog").load("<%=ServerValue.getFrontContextPath()%>/shopping/orderInfo/loadMobilVaild.do"),500,'auto');
                    }else{
                     serviceSupportMessage("30");
                    }
                  }
                   }else{
                        serviceSupportMessage("30");
                   }
              });

              <c-rt:if test="${'on' eq useCreditcardPeriod and not empty creditcard and chkAvailableDetails}">
                   $("#periodDiv").hide();
                   $("#periodAmountDiv").hide();

                   $("#creditcardDetailId").change(function(){
                        $("#editPeriod").val("0");
                        $("#editPeriodFee").val("0.0");
                        $("#periodSpan").text("");
                        $("#periodAmount").text("0.0");
                        $("#periodAmountDiv").hide();
                        $("#periodMoney").text("");
                        $("#finalPeriodMoney1").text("");
                        $("#finalPeriodMoney2").text("");
                        $("#pPeriodTotalAmount").text("");
                        $("#editPeriodAmount").val("0.0");
                        $("#showPeriodAmount").hide();
                        ProcessCalcuTotal();
                        if ( $(this).val() == "" ){
                             $("#paytype80").attr("checked",false);
                             $("#periodDiv").hide();
                        }else{
                             $("#paytype80").attr("checked",true);
                             $("#periodDiv").show();
                             $("#periodSpan").show();
                             $.post("<%=ServerValue.getFrontContextPath()%>/shopping/jsonGetCreditcardDetail.do",{creditcardDetailId:$("#creditcardDetailId").val()},
                        function callback(creditcardDetailEntity){
                                 alert(creditcardDetailEntity);
                                      if(null != creditcardDetailEntity){
                                           var temp = "";
                                           for( var period in creditcardDetailEntity.periodMap){
                                                if ( $("#finalMustPay").val() >= parseFloat(creditcardDetailEntity.downLimitMap[period]) &&
                                                          $("#finalMustPay").val() <= parseFloat(creditcardDetailEntity.upLimitMap[period]) ){
                                                     temp = temp + "<label><input type='radio' value='" + period + "," + creditcardDetailEntity.feeMap[period] + "' name='period' onclick='calcPeriodFee(this.value);' /><strong class='txt-rd'>" + period + "</strong>期&nbsp;&nbsp;&nbsp;</label>";
                                                }
                                           }
                                           alert(temp);
                                           $("#periodSpan").append(temp);
                                      }
                             },
                        "json");
                        }
                   });               
              </c-rt:if>
              <%--发票信息--%>
              $("#invotype01").attr("checked",true);
              $("#invoTitle").hide();
              $('#invotype01').click(function(){
                   $("#invoTitle").val("");
                   $("#invoTitle").hide();
              });
              $('#invotype02').click(function(){
                   $("#invoTitle").show();
              });
              <%--處理收货人是否輸入--%>
              $("#go_next").click(function() { 
                   if(isGoNext==true){
                        alertDialog('订单', '订单正在处理中，稍等');
                        return;
                   }
                   isGoNext=true;
                   ProcessCalcuTotal();

                   if($("#memo").val()=="(非必填项目，可在此说明对商品的特殊需求，我们虽無法保證，但将努力配合您的需求。)"){
                        $("#memo").val("");
                   }
                            
                   $("#contactNameTip").hide();
                   $("#addrTip").hide();
                   $("#telTip").hide();   
                   $("#provinceTip").hide();
                   $("#mailTip").hide();

                   if(numberCount($("#contactName").val())>0){
                        $("#contactNameTip").text("不允许数字输入");
                        $("#contactNameTip").show();
                        $("#contactName").focus();
                        isGoNext=false;
                        return false;
                   }
         
                   if(chineseCount($("#addr").val())==0){
                        $("#addrTip").text("不允许全部数字输入");
                        $("#addrTip").show();
                        $("#addr").focus();
                        isGoNext=false;
                        return false;
                   }

                   if ( $('input[id=paytype10]').is(":checked") == true || $('input[id=paytype20]').is(":checked") == true || $('input[id=paytype30]').is(":checked") == true
                             || $('input[id=paytype40]').is(":checked") == true|| $('input[id=paytype50]').is(":checked") == true|| $('input[id=paytype70]').is(":checked") == true|| $('input[id=paytype80]').is(":checked") == true){
                        if("on"=="<%=ServerValue.getBlockOrderPaymentType()%>"){
                    if(${member.applySource eq 'nonmember'}){
                     checkLoginMember("#");
                     isGoNext=false;
                                  return false;
                          }else{
                                  if($("#ismobileVaild").val()=="false"){
                 openDialog("手机验证",$("#mobileVaildDialog").load("<%=ServerValue.getFrontContextPath()%>/shopping/orderInfo/loadMobilVaild.do"),500,'auto');
                isGoNext=false;
                                      return false;
                 }
                    }
                        }
                   }

                   if ($('input[id=paytype30]').is(":checked") == true || $('input[id=paytypeCash]').is(":checked") == true ||$('input[id=paytypePos]').is(":checked") == true){                                       
                        $.post("<%=ServerValue.getFrontContextPath()%>/shopping/orderInfo/isCodForBadOrder.do",{addr:$('#addr').val(),mobile:$('#mobile').val(),phone:$('#phone').val()},
                                  function callback(result){
                                       if(result.indexOf('异常')>0){
                                           disableCOD();
                                           alert("该订单超过货到付款使用限制，请改使用其他支付方式");
                                           if(result.split(",")[1]=='true'){
                                                $("#disableCod").val('true');
                                           }else{
                                                $("#disableCod").val('false');
                                           }
                                        // alert("2:"+$("#disableCod").val());
                                           //isGoNext=false;
                                           //return false;
                                      }else{
                                           $("#disableCod").val('false');
                                      }
                                  },"json");
                        if($("#disableCod").val()=='true'){
                             isGoNext=false;
                             return false;
                        }
                   }   
                  
                   var inputResult = saveInput("", -1, $("#contactName").val(),$("#province").find('option:selected').text(),$("#city").find('option:selected').text(),$("#district").find('option:selected').text(),$("#addr").val(),$("#zipCode").val(),$("#mobile").val(),$("#areaCode").val(),$("#phone").val(),$("#extension").val());
                   if(inputResult!=null && inputResult[0]=="false"){
                        if(inputResult[1]!=""){
                             $("#contactNameTip").show();
                        }
                        if(inputResult[2]!=""){
                             $("#addrTip").text(inputResult[2]);
                             $("#addrTip").show();
                        }
                        if(inputResult[3]!=""){
                             $("#telTip").text(inputResult[3]);
                             $("#telTip").show();
                        }   
                        if($("#province").find('option:selected').val()==""){
                             $("#provinceTip").text("请选择省");
                             $("#provinceTip").show();
                        }
                        $("#myAddBook").focus();
                   }else{
                        if(isNaN(parseInt($("#zipCode").val(), 10))==true && $("#zipCode").val() !=""){
                             $("#addrTip").text("邮编错误");
                             $("#addrTip").show();
                             $("#zipCode").focus();
                             isGoNext=false;
                             return false;
                        }
                        if($("#addr").val().length >100){
                             $("#addrTip").text("街道过长");
                             $("#addrTip").show();
                             $("#addr").focus();
                             isGoNext=false;
                             return false;
                        }
                        if(trim($("#mobile").val()).length >=1 &&trim($("#mobile").val()).length <9){
                             $("#telTip").text("手机号码至少要九码");
                             $("#telTip").show();
                             $("#mobile").focus();
                             isGoNext=false;
                             return false;
                        }
                        if(isNaN(parseInt(trim($("#mobile").val()), 10))==true && trim($("#mobile").val()) !=""){
                             $("#telTip").text("手机号码请使用半角数字");
                             $("#telTip").show();
                             $("#mobile").focus();
                             isGoNext=false;
                             return false;
                        }
                        if(isNaN(parseInt(trim($("#areaCode").val()), 10))==true && trim($("#areaCode").val()) !=""){
                             $("#telTip").text("固定电话请使用半角数字");
                             $("#telTip").show();
                             $("#areaCode").focus();
                             isGoNext=false;
                             return false;
                        }
                        if(isNaN(parseInt(trim($("#phone").val()), 10))==true && trim($("#phone").val()) !=""){
                             $("#telTip").text("固定电话请使用半角数字");
                             $("#telTip").show();
                             $("#phone").focus();
                             isGoNext=false;
                             return false;
                        }
                        if(isNaN(parseInt(trim($("#extension").val()), 10))==true && trim($("#extension").val()) !=""){
                             $("#telTip").text("固定电话请使用半角数字");
                             $("#telTip").show();
                             $("#extension").focus();
                             isGoNext=false;
                             return false;
                        }
                        if( $("#zipCode").val() ==""){
                             $("#addrTip").text("请输入邮编");
                             $("#addrTip").show();
                             $("#zipCode").focus();
                             isGoNext=false;
                             return false;
                        }
                        if($("#province").find('option:selected').val()==""){
                             $("#provinceTip").text("请选择省");
                             $("#provinceTip").show();
                             isGoNext=false;
                             return false;
                        }        
                        if($("#city").find('option:selected').val()==""){
                             $("#provinceTip").text("请选择城市");
                             $("#provinceTip").show();
                             isGoNext=false;
                             return false;
                        }
                        if($("#district").find('option:selected').val()==""){
                             $("#provinceTip").text("请选择地区");
                             $("#provinceTip").show();
                             isGoNext=false;
                             return false;
                        }
                            
                        <c-rt:if test="${member.email=='xx'}">
                             $("#mail").val(jQuery.trim($("#mail").val()).toLowerCase());
                   if($("#mail").val() == "xx"){
                   $("#mailTip").attr("class","msg rn");
                   $("#mailTip").html("请输入联络邮箱");
                   //alertDialog('联络邮箱', '请输入联络邮箱',"",350,120);
                   $("#mailTip").show();
              isGoNext=false;
              return false;
              }else if($("#mail").val().match(/.+@.+\..+/)==null || $("#mail").val().indexOf(' ')>=0 || chineseCount($("#mail").val())>0){
                   $("#mailTip").attr("class","msg rn");
                   if(jQuery.trim($("#mail").val())==''){
                        $("#mailTip").html("请输入联络邮箱");
                   }else{
                        $("#mailTip").html("邮箱格式错误");
                   }
                   $("#myAddBook").focus();    
                   //isCorrect = false;
                   //alertDialog('邮箱格式错误', '邮箱格式错误',"",350,120);
                   $("#mailTip").show();
              isGoNext=false;
              return false;
                        }
              </c-rt:if>
                        if ($('input[name=paytype]').is(":checked") == false){
                             alert("请选择付款方式");
                             $('#paytype50').attr("checked",true);
                             $('#paytype50').focus();    
                             isGoNext=false;
                             return false;
                        }
                        if($("#useWallet").css("display") != "none"){
                             alert("若要使用帐户余额，请按「确认使用」按钮，否则请反勾选。");
                             $("#chkVrtBlnc").focus();
                             isGoNext=false;
                             return false;
                        }                           
                        if ($("#chkVrtBlnc").attr('checked')){
                             var tmpSubVB=0.0;
                             if($("#subVrtlBlnc").val()==""){
                    tmpSubVB=$("#subVrtlBlnc").val(0.0);
                   }else{
                        tmpSubVB=parseFloat($("#subVrtlBlnc").val()).toFixed(1);
                   }                                
                    //$("#chkVrtBlnc").val(parseFloat($("#subVrtlBlnc").val()).toFixed(2));
                    $("#chkVrtBlnc").val(tmpSubVB);
                    //if(parseFloat($("#subVrtlBlnc").val())>parseFloat($("#myVirtualBalance").text())){
                    if(parseFloat(tmpSubVB)>parseFloat($("#myVirtualBalance").text())){
                                  alert('您输入的金额大于帐户余额，请重新输入抵用金额。');
                                  $("#subVrtlBlnc").focus();
                                  isGoNext=false;
                                  return false;
                             }
                } else {
                    $("#chkVrtBlnc").val(0.0);  
                }  
                  if(parseFloat($("#chkVrtBlnc").val())>parseFloat($("#finalTotalAmount").val())){
                             alert('帐户余额不可大於实际应缴总金额');
                             $("#subVrtlBlnc").focus();
                             isGoNext=false;
                             return false;
                        }
                  if($("#useGiftCard").css("display") != "none"){
                             alert("若要使用礼品卡，请按「确认使用」按钮，否则请反勾选。");
                             $("#chkGiftCard").focus();
                             isGoNext=false;
                             return false;
                        }                           
                        if ($("#chkGiftCard").attr('checked')){
                             var tmpSubGC=0.0;
                             if($("#subGiftCard").val()==""){
                                  tmpSubGC=$("#subGiftCard").val(0.0);
                   }else{
                        tmpSubGC=parseFloat($("#subGiftCard").val()).toFixed(1);
                   }                                
                    $("#chkGiftCard").val(tmpSubGC);
                    if(parseFloat(tmpSubGC)>parseFloat($("#myGiftCardBalance").text())){
                                  alert('您输入的金额大于礼品卡余额，请重新输入抵用金额。');
                                  $("#subGiftCard").focus();
                                  isGoNext=false;
                                  return false;
                             }
                } else {
                    $("#chkGiftCard").val(0.0);  
                }  
              if(parseFloat($("#chkGiftCard").val())>parseFloat($("#finalTotalAmount").val())){
                        alert('礼品卡不可大於实际应缴总金额');
                        $("#subGiftCard").focus();
                        isGoNext=false;
                        return false;
                   }                 
                  if ($('input[id=paytype30]').is(":checked") == true){
              if(trim($("#mobile").val())==""){
                   alertDialog('填手机号码', '选择货到付款必须填手机号码',"",350,120);
                   isGoNext=false;
              return false;
              }
              }
                if ($('input[id=paytype40]').is(":checked") == true){
                     if(parseFloat($("#finalMustPay").val())>0){
                        alert('使用全额由我的帐户余额/礼券付清，但剩余应付金额大于0，请重新选择');
                        isGoNext=false;
                        return false;
                             }
                }
                if(parseFloat($("#finalMustPay").val())<0){
              alert('剩余应付金额不可为负，请重新选择');
              isGoNext=false;
              return false;
                        }
           if(parseFloat($("#finalTotalAmount").val())<0){
              alert('订单金额不可为负，请重新选择');
              isGoNext=false;
              return false;
                        }
          <c-rt:if test="${fn:length(cartOrders.cartOrderProducts)>1}">
          if ($('input[name=allowSplit]').is(":checked") == false){
						if ($('input[id=paytype30]').is(":checked") == true){
		        	$("#allowSplitY").attr("disabled",true); //cod不允许拆单
		        	$("#allowSplitY").attr("checked",false);
		        	$("#allowSplitN").attr("checked",true); 
						}else{
							alert("您尚未选择〝商品缺货配送处理方法〞，我们将默认为〝有货先发〞。");
							$("#allowSplitY").attr("disabled",false); //cod允许拆单
							$("#allowSplitY").attr("checked",true);
				      $("#allowSplitN").attr("checked",false); 
						}
						isGoNext=false;
						return false;
					}
					</c-rt:if>
			    if(parseFloat($("#finalMustPay").val())==0){
			    	$("input[type='radio'][name='paytype']").each(function(){
							var payId = $(this).attr("id"); 
			      	if ($('input[id=' + payId + ']').is(":checked") == true){
				      	if ( payId == "paytype50" ){
  	    	   			alert('剩余应付金额为0，不可选网上支付，请重新选择');
				      	}else if ( payId == "paytype20" ){
				      		alert('剩余应付金额为0，不可选邮局汇款，请重新选择');
				      	}else if ( payId == "paytype10" ){
				      		alert('剩余应付金额为0，不可选银行汇款，请重新选择');
				      	}else if ( payId == "paytype30" ){
				      		alert('剩余应付金额为0，不可选货到付款，请重新选择');
				      	}else if ( payId == "paytype70" ){
				      		alert('剩余应付金额为0，不可选信用卡：一次付清，请重新选择');
				      	}else if ( payId == "paytype80" ){
				      		alert('剩余应付金额为0，不可选信用卡：分期付款，请重新选择');
				      	}
    	       		isGoNext=false;
      	     		return false;
       	 	 		}
			    	});
					}
                  if ($("#invotype02").is(":checked") == true){
              if($("#invoTitle").val()==""){
              alert('请输入单位');
              $("#invoTitle").focus();
              isGoNext=false;
              return false;
                             }
               if($("#invoTitle").val().length+chineseCount($("#invoTitle").val())>40){
                   alert("请使用 中文20个字以内 或 英文40个字以内");
                   $("#invoTitle").focus();
                   isGoNext=false;
              return false;
               }
               }   
                        <%--儲存收件人--%>
                        var districtTxt = $("#district").find('option:selected').text();
                        if(districtTxt.substring(0,1)=='※'){
                             districtTxt=districtTxt.substring(1);
                        }                           
            $.post("<%=ServerValue.getFrontContextPath()%>/member/saveAddressBook.do",{abId:-1,contactName:$('#contactName').val(),province:$('#province').find('option:selected').text(),city:$('#city').find('option:selected').text(),district:districtTxt,zipCode:$('#zipCode').val(),addr:$('#addr').val(),mobile:$('#mobile').val(),areaCode:$("#areaCode").val(),phone:$('#phone').val(),extension:$('#extension').val()},
                        function callback(result){
                             //alert("saveAddressBook_result:"+result);
                             },
                        "json");
                             <c-rt:choose>
                         <c-rt:when test="${needValidateNum}">
                        <%--输入验证码--%>
                         if(($("#ccode").val() == "")){
                        $("#ccode").focus();   
                            $("#codeTip").html('请输入校验码');
                            $("#codeTip").show();
                            isGoNext=false;
                                      return false;
                         }else{
                          $.post("<%=ServerValue.getFrontContextPath()%>/shopping/jsonChkValidateNum.do",{ccode:$("#ccode").val()},
                                 ccodeCallback,"json");
                         }
                         </c-rt:when>
                         <c-rt:otherwise>
                             if ( $('input[id=paytype80]').is(":checked") == true ){
                                  <c-rt:choose>
                                      <c-rt:when test="${'on' eq useCreditcardPeriod and not empty creditcard and chkAvailableDetails}">
                                           $.post("<%=ServerValue.getFrontContextPath()%>/shopping/jsonChkValidCreditcardDetail.do",{productId:'<%=request.getParameter("itemNo")%>',creditcardDetailId:$("#creditcardDetailId").val(),period:$("#editPeriod").val(),finalTotalAmount:$("#closeFinalTotalAmount").val()},
                                                creditcardDetailCallback,"json");
                                      </c-rt:when>
                                      <c-rt:otherwise>
                                           $("#go_next").hide();
                                                     $("#go_back").hide();
                                                     $("#paymentInfoForm").submit();
                                                     return false;
                                      </c-rt:otherwise>
                                  </c-rt:choose>
                             }else{
                                 $("#go_next").hide();
                                           $("#go_back").hide();
                                           $("#paymentInfoForm").submit();
                                           return false;
                             }
                         </c-rt:otherwise>
                    </c-rt:choose>
                        }
                   isGoNext=false;
              });

              function ccodeCallback(ccodeResult){
               if(ccodeResult == "error"){
                   $("#ccode").focus();   
                        $("#codeTip").html('验证码错误，请重新输入');
                        $("#iv").attr("src","<%=ServerValue.getFrontContextPath()%>/servlet/imageValid.jpg?"+Math.random());
                        $("#codeTip").show();
                        isGoNext=false;
                        return false;
                   }else{
                        <c-rt:choose>
                        <c-rt:when test="${'on' eq useCreditcardPeriod and not empty creditcard and chkAvailableDetails}">
                             if ( $('input[id=paytype80]').is(":checked") == true ){
                                  $.post("<%=ServerValue.getFrontContextPath()%>/shopping/jsonChkValidCreditcardDetail.do",{productId:'<%=request.getParameter("itemNo")%>',creditcardDetailId:$("#creditcardDetailId").val(),period:$("#editPeriod").val(),finalTotalAmount:$("#closeFinalTotalAmount").val()},
                                  creditcardDetailCallback,"json");
                             }else{
                                  <%--調整: 訂購流程_商品&赠品不足之检查--%>
                                       $("#go_next").hide();
                                       $("#go_back").hide();
                                       $("#paymentInfoForm").submit();
                                      //return true;
                                      return false;
                             }
                        </c-rt:when>
                        <c-rt:otherwise>
                        <%--調整: 訂購流程_商品&赠品不足之检查--%>
                                  $("#go_next").hide();
                                  $("#go_back").hide();
                                  $("#paymentInfoForm").submit();
                                  //return true;
                                  return false;
                        </c-rt:otherwise>
                    </c-rt:choose>
                   }
              }

              function creditcardDetailCallback(creditcardDetailResult){
                   if ( "error" == creditcardDetailResult ){
                        alert("订单选择之信用卡分期支付方式不符活动规则，请重新结帐。");
                        isGoNext=false;
                        return false;
                   }else{
                        <%--調整: 訂購流程_商品&赠品不足之检查--%>
                        $("#go_next").hide();
                        $("#go_back").hide();
                        $("#paymentInfoForm").submit();
                        //return true;
                        return false;
                   }
              }
             
              function saveInput(text, abId, iName, iProvince, iCity, iDistrict, iStreet, iZip, iMobile, iAreaCode, iPhone, iExte){
                   var inputCorrect = true;
                   var a_msg = new Array();
                   a_msg[0]="true";

                   a_msg[1]="";
                   if(iName == "(请输入收货人姓名)"){
                        a_msg[0]="false";
                        a_msg[1]="请输入收件人姓名";
                   }
                  
                   a_msg[2]="";
                   if(iProvince == ""){
                        a_msg[0]="false";
                        a_msg[2]="请选择省";
                   }

                   if(iZip == ""){
                        a_msg[0]="false";
                        if(a_msg[2].length!=0){a_msg[2]+="，";}
                        a_msg[2]+="请输入邮编";
                   }
                  
                   if(iStreet == "(输入街道地址，例如：和平路12巷52号)"){
                        a_msg[0]="false";
                        if(a_msg[2].length!=0){a_msg[2]+="，";}
                        a_msg[2]+="请输入街道";
                   }

                   a_msg[3]="";
                   if(trim(iMobile)=="" && trim(iPhone)==""){
                        a_msg[0]="false";
                        a_msg[3]="请至少填写一组电话";
                   }
                  
                   if(iPhone!="" && iAreaCode==""){
                        a_msg[0]="false";
                        a_msg[3]="请输入区码";
                   }
                  
                   iStreet = iStreet.replace(/，/ig,",");
                   a_msg[4] = iProvince+"，"+iCity+"，"+iDistrict+"，"+iStreet+"，"+iZip;
                   if(a_msg[0]=="true"){
                        a_msg[5] = "";    
                        //can go next
                        return null;
                   }else{
                        return a_msg;
                   }
              }   

              <%--計算实际应付总金额--%>
              ProcessCalcuTotal();
             
              <%--處理帳戶餘額chkVrtBlnc--%>   
              $('#chkVrtBlnc').click(function(){
                   $("#subVrtlBlnc").css("background-color","white");   
           if (this.checked){
            initPaytype();
          $("#useWallet").show();
          $("#subVrtlBlnc").attr("readOnly", false);
          if($("#subVrtlBlnc").val()==""){
                   $("#chkVrtBlnc").val(0.0);
                   $("#subVrtlBlnc2").val(0.0);
                   }else{
                        $("#chkVrtBlnc").val($("#subVrtlBlnc").val());
                        $("#subVrtlBlnc2").val($("#subVrtlBlnc").val());
                   }
              if("on"=="<%=ServerValue.getBlockOrderPaymentType()%>"){
                    if(${member.applySource eq 'nonmember'}){
                     checkLoginMember("#");
                    }else{
                                  if($("#ismobileVaild").val()=="false"){
                openDialog("手机验证",$("#mobileVaildDialog").load("<%=ServerValue.getFrontContextPath()%>/shopping/orderInfo/loadMobilVaild.do"),500,'auto');
                    }
                    }
                        }
           }else {
            initWallet();
           }
           ProcessCalcuTotal();
         });
               $("#confirmWallet").click(function(){
                    initAllowSplit();
                   if($("#subVrtlBlnc").val()==""){
                   $("#chkVrtBlnc").val(0.0);
                   $("#subVrtlBlnc2").val(0.0);
              }else{
                        $("#chkVrtBlnc").val(parseFloat($("#subVrtlBlnc").val()).toFixed(1));
                        $("#subVrtlBlnc2").val(parseFloat($("#subVrtlBlnc").val()).toFixed(1));
              }           
        ProcessCalcuTotal();
        var tmpSVB=0.0;
        if($("#subVrtlBlnc").val()==""){
          tmpSVB=0.0;
          }else{
              tmpSVB=$("#subVrtlBlnc").val();
          }
        if(parseFloat($("#finalMustPay").val())<0){
          alert("您输入的支付金额超过了订单金额，请重新输入欲支付金额。");
          $("#subVrtlBlnc").focus();
        }else if(parseFloat(tmpSVB)>parseFloat($("#myVirtualBalance").text())){
                        alert('您输入的金额大于帐户余额，请重新输入抵用金额。');
                        $("#subVrtlBlnc").focus();
                   }else if(parseFloat($("#finalMustPay").val())==0){
                        $("#allpaymsg").show();
                        if( isNaN($("#subGiftCard").val()) || isNaN($("#subGiftCard2").val()) ){
                             $("#chkGiftCard").attr("checked",false);
                             $("#subGiftCard").val(0.0);
                             $("#subGiftCard2").val(0.0);
                        }
          $("input[id^='paytype']").each(function(i){
                             if(this.id=='paytype40'){
                                  $(this).attr("disabled", false);
                                  $(this).attr("checked", true);
                             }else{
                                  $(this).attr("disabled", true);
                                  $(this).attr("checked", false);
                             }
                        });
          $("#useWallet").hide();
          $("#subVrtlBlnc").attr("readOnly", true);
          $("#subVrtlBlnc").css("background-color","silver");
          ProcessCalcuTotal();
        }else{
                        $("#useWallet").hide();
              $("#subVrtlBlnc").attr("readOnly", true);
               $("#subVrtlBlnc").css("background-color","silver");
              ProcessCalcuTotal();
        }
      });    

              <%--處理礼品卡餘額chkGiftCard--%>
              $('#chkGiftCard').click(function(){
                   $("#subGiftCard").css("background-color","white");   
           if (this.checked){
            initPaytype();
          $("#useGiftCard").show();
          $("#subGiftCard").attr("readOnly", false);
          if($("#subGiftCard").val()==""){
                   $("#chkGiftCard").val(0.0);
                   $("#subGiftCard2").val(0.0);
                   }else{
                        $("#chkGiftCard").val($("#subGiftCard").val());
                        $("#subGiftCard2").val($("#subGiftCard").val());
                   }
              if("on"=="<%=ServerValue.getBlockOrderPaymentType()%>"){
                    if(${member.applySource eq 'nonmember'}){
                     checkLoginMember("#");
                    }else{
                                  if($("#ismobileVaild").val()=="false"){
                        openDialog("手机验证",$("#mobileVaildDialog").load("<%=ServerValue.getFrontContextPath()%>/shopping/orderInfo/loadMobilVaild.do"),500,'auto');
                      }
                   }
                        }
           }else {
             initGiftCard();
           }
           ProcessCalcuTotal();
         });
               $("#confirmGiftCard").click(function(){   
                    initAllowSplit();
                   if($("#subGiftCard").val()==""){
                   $("#chkGiftCard").val(0.0);
                   $("#subGiftCard2").val(0.0);
              }else{
                    $("#chkGiftCard").val(parseFloat($("#subGiftCard").val()).toFixed(1));
            $("#subGiftCard2").val(parseFloat($("#subGiftCard").val()).toFixed(1));
              }      
                   ProcessCalcuTotal();   
         //alert($("#finalMustPay").val());
         var tmpSVB=0.0;
         if($("#subGiftCard").val()==""){
              tmpSVB=0.0;
          }else{
              tmpSVB=$("#subGiftCard").val();
          }
      
        if(parseFloat($("#finalMustPay").val())<0){
           alert("您输入的支付金额超过了订单金额，请重新输入欲支付金额。");
           $("#subGiftCard").focus();
        }else if(parseFloat(tmpSVB)>parseFloat($("#myGiftCardBalance").text())){
                        alert('您输入的金额大于礼品卡余额，请重新输入抵用金额。');
                        $("#subGiftCard").focus();
                   }else if(parseFloat($("#finalMustPay").val())==0){
                        $("#allpaymsg").show();
                        if( isNaN($("#subVrtlBlnc").val()) || isNaN($("#subVrtlBlnc2").val()) ){
                             $("#chkVrtlBlnc").attr("checked",false);
                             $("#subVrtlBlnc").val(0.0);
                             $("#subVrtlBlnc2").val(0.0);
                        }
          $("input[id^='paytype']").each(function(i){
                             if(this.id=='paytype40'){
                                  $(this).attr("disabled", false);
                                  $(this).attr("checked", true);
                             }else{
                                  $(this).attr("disabled", true);
                                  $(this).attr("checked", false);
                             }
                        });
          $("#useGiftCard").hide();
          $("#subGiftCard").attr("readOnly", true);
          $("#subGiftCard").css("background-color","silver");
          ProcessCalcuTotal();
        }else{
                        $("#useGiftCard").hide();
              $("#subGiftCard").attr("readOnly", true);
               $("#subGiftCard").css("background-color","silver");
              ProcessCalcuTotal();
        }
      });    
                            
             
              <%--初始可折抵的購物金--%>
                   function processBonus(minusCoupon){
                        var iOffset=0;
                        var iCanUse=$("#canUse").val();
                        if( "${not empty bonusCampaign}" && parseInt(iCanUse,10)>0){
                             ieditTotalAmount=sfinalTotalAmount-parseInt(minusCoupon,10);
                             <%--积分折抵上限(無條件進位)--%>
                             iOffset=Math.ceil(parseInt(ieditTotalAmount,10)*parseInt("${bonusCampaign.offsetUpperLimit}",10)/100);
                             iOffset=parseInt(iOffset,10);
                             <%--积分折抵上限不可超过可使用的积分限制--%>
                             if ( iOffset > parseInt(iCanUse,10) ){
                                  iOffset = parseInt(iCanUse,10);
                             }
                             <%--可使用的积分限制不可超过订单最大可抵折积分限制--%>
                             if ( iOffset > parseInt("${bonusCampaign.offsetDiscountLimit}",10)){
                                  iOffset = parseInt("${bonusCampaign.offsetDiscountLimit}",10);
                             }
                             $("#offset").text(iOffset.toFixed(1));
                             $("#offsetBonus").text(iOffset*parseInt("${bonusCampaign.offsetRate}",10));
                             if($("#chkBonus").attr('checked')==true){
                                  $("#editBonus").val(iOffset.toFixed(1));       
                                  $("#editOffsetBonus").text(iOffset*parseInt("${bonusCampaign.offsetRate}",10));
                             }
                        }else{
                             $("#offset").text(iOffset.toFixed(1));
                             $("#offsetBonus").text("0");
                             $("#editOffsetBonus").text("0");
                             $("#chkBonus").attr('disabled',true);
                        }
                   }

                   $("#province").change(function() {
                        var optionsCity = '<option value="">== 选择城市 ==</option>';
                        $("#city").html(optionsCity);
                        var options = '<option value="">== 选择地区 ==</option>';
                        $("#district").html(options);
                        $("#displayPOS").hide();
                        queryProvince2('','');
                        initCoupon();
                                      initBonus();
                        initWallet();
                        initGiftCard();
                        <%--计算运费--%>
                        var tmpProvince=$("#province").find('option:selected').val();
                             //setTimeout(FreightCod,400);
                        FreightCod(tmpProvince);
                 });   

                   $("#city").change(function() {
                        queryCity2('');
                });    

                   $("#district").change(function() {
                        queryDistinct();
                        initWallet();
                        initGiftCard();
                        <%--判断是否可货到付款--%>
                        var tmpCity=$("#city").find('option:selected').val();
                        var tmpDistrict=$("#district").find('option:selected').text();
                             if(tmpDistrict.substring(0,1)=='※' && "${canUseCod}"  == "true"){
                                  $("#paytype30").attr("disabled",false);
                                  $("#paytypeCash").attr("disabled",false);
                                  $("#paytypePos").attr("disabled",false);
                                  $("#showOrderPriceLimit").html("(需加收手续费 ${codFee} 元)");
                             }else{
                                  $("#paytype30").attr("disabled",true);
                                  $("#paytype30").attr("checked",false);
                                  $("#paytypeCash").attr("disabled",true);
                                  $("#paytypeCash").attr("checked",false);
                                  $("#paytypePos").attr("disabled",true);
                                  $("#paytypePos").attr("checked",false);
                                  $("#showOrderPriceLimit").html("(需加收手续费 ${codFee} 元)");
                             }   
                        //serviceSupportMessage();
                        isPos();
                    }); 

                   $("#iv").attr("src","<%=ServerValue.getFrontContextPath()%>/servlet/imageValid.jpg?"+Math.random());
     });
     function FreightCod(tmpProvince){
          var addCmpPd=$("#addCmpPd").val();
          var tmpFinalMustPay=$("#editTotalAmount").val();
          var buyNowCartId=$("#buyNowCartId").val();
          if(parseFloat($("#finalTotalAmount").val())>10000){
              $("#paytype30").attr("disabled",true);
              $("#paytype30").attr("checked",false);
              $("#paytypeCash").attr("disabled",true);
              $("#paytypeCash").attr("checked",false);
              $("#paytypePos").attr("disabled",true);
              $("#paytypePos").attr("checked",false);
              $("#showOrderPriceLimit").html("(订单金额超过10000元，将不提供货到付款服务。)");
              $("#displayPOS").hide();
               caleShipFare(tmpProvince,"N",tmpFinalMustPay,addCmpPd,buyNowCartId);       
              isPos();
          }else{
              var tmpDistrict=$("#district").find('option:selected').text();
              if(tmpDistrict.substring(0,1)=='※'){
                   $("#paytype30").attr("disabled",false);
                   $("#paytypeCash").attr("disabled",false);
                   $("#paytypePos").attr("disabled",false);
                   $("#displayPOS").show();
              }else{
                   $("#paytype30").attr("disabled",true);
                   $("#paytype30").attr("checked",false);
                   $("#paytypeCash").attr("disabled",true);
                   $("#paytypeCash").attr("checked",false);
                   $("#paytypePos").attr("disabled",true);
                   $("#paytypePos").attr("checked",false);
                   $("#showOrderPriceLimit").html("(需加收手续费 ${codFee} 元)");
                   $("#displayPOS").hide();
              }
               caleShipFare(tmpProvince,"N",tmpFinalMustPay,addCmpPd,buyNowCartId);       
              clearTimeout;
              isPos();
          }
     }
     function callback(result){
          $("#spanFreight").text(result);
          $("#editShipFare").val(parseFloat(result).toFixed(1));
          ProcessCalcuTotal();
     }   
     <c-rt:set scope="request" var="totalPrice" value="0"/>
     <c-rt:forEach items="${cartOrders.cartOrderProducts}" var="cop">
     <c-rt:set var="copDiscount" value="${cop.discount}" scope="request"/>
     <c-rt:if test="${!empty totalDiscount}">
          <c-rt:set scope="request" var="totalDiscount" value="${pu:toFloat(totalDiscount)+pu:toFloat(copDiscount)}"/>
     </c-rt:if>
     <c-rt:if test="${empty totalDiscount}">
          <c-rt:set scope="request" var="totalDiscount" value="${copDiscount}"/>
     </c-rt:if>
          <c-rt:set scope="request" var="totalPrice" value="${pu:toFloat(totalPrice)+pu:toFloat(cop.totalPrice)}"/>
  </c-rt:forEach> 
  var totalDiscount='${cartOrders.discount}';
  if(totalDiscount==''){
       totalDiscount=0.0;
  }else{
       totalDiscount=parseFloat(totalDiscount);
  }
  var totalPrice='${totalPrice}';
  if(totalPrice=='')totalPrice=0.0;
     var sfinalTotalAmount=0.0;
     function ProcessCalcuTotal(){
          <%--购物金的计算规则(商品总额-折扣)--%>
          sfinalTotalAmount=calcuTotal(parseFloat(totalPrice)-totalDiscount,0,0,$("#editBonus").val());
          var sumAmount=0.0;
          $("input[id*='editAmount_']").each(function(){ 
               sumAmount=parseFloat(sumAmount)+parseFloat($(this).val());
              sumAmount =sumAmount.toFixed(1);
          });
          $("#editTotalAmount").val(sumAmount); <%--合计金额--%>
          finalTotalAmount=calcuTotal(sumAmount-totalDiscount,$("#editShipFare").val(),$("#editCoupon").val(),$("#editBonus").val());
          <%--COD﹣收取手續費--%>
          if ($('input[id=paytype30]').is(":checked") == true){
               finalTotalAmount=parseFloat(finalTotalAmount)+parseFloat(${codFee});
               $("#codFee").val(parseFloat(${codFee}).toFixed(1));
               $("#codFee2").html(parseFloat(${codFee}).toFixed(1));
          }else{
               finalTotalAmount=calcuTotal(sumAmount-totalDiscount,$("#editShipFare").val(),$("#editCoupon").val(),$("#editBonus").val());
              $("#codFee").val("0.0");
              $("#codFee2").html("0.0");
          }
          if(finalTotalAmount<0)finalTotalAmount=$("#editShipFare").val();
         
          $("#finalTotalAmount").val(finalTotalAmount);     <%--实际应付总金额-订单明细-关闭订单明细--%>
          $("#pTotalAmount").text($("#editTotalAmount").val());<%--付款方式-商品合计金额--%>
          $("#pCoupon").text($("#editCoupon").val());<%--付款方式-礼券--%>
          $("#pBonus").text($("#editBonus").val());<%--付款方式-积分金额--%>
          $("#pOffsetBonus").text($("#editOffsetBonus").text());<%--付款方式-积分--%>
          $("#pShipFare").text($("#editShipFare").val());<%--付款方式-运费--%>
          if ( $("#chkGiftCard").attr("checked") && $("#useGiftCard").is(':hidden') ){
              if ( "" == $("#subGiftCard").val() ){
                   $("#pGiftCard").text(0.0);
              }else{
                   $("#pGiftCard").text($("#subGiftCard").val());<%--付款方式-礼品卡--%>
              }
          }else{
              $("#pGiftCard").text(0.0);
          }
          if ( $("#chkVrtBlnc").attr("checked") &&  $("#useWallet").is(':hidden') ){
              if ( "" == $("#subVrtlBlnc").val() ){
                   $("#pVirtualBalance").text(0.0);
              }else{
                   $("#pVirtualBalance").text($("#subVrtlBlnc").val());<%--付款方式-帐户余额--%>
              }
          }else{
              $("#pVirtualBalance").text(0.0);
          }
          if(totalDiscount==0){
              $('#pDiscount').text(totalDiscount);
              $('#totalDiscount').attr('value', totalDiscount);
          }else{
               $('#pDiscount').text(totalDiscount.toFixed(1));
              $('#totalDiscount').attr('value', totalDiscount.toFixed(1));
          }
          $("#pFinalTotalAmount").text((finalTotalAmount-parseFloat($("#pVirtualBalance").text())-parseFloat($("#pGiftCard").text())).toFixed(1));<%--付款方式-订单金额--%>
          /*
          alert($("#chkVrtBlnc").is(":checked") == true);
          alert($("#useWallet").attr("style") );
     if ( $("#chkVrtBlnc").is(":checked") == true && $("#useWallet").attr("display") == "none"){
             alert(parseFloat($("#subVrtlBlnc2").val()).toFixed(1));
          if ( parseFloat($("#subVrtlBlnc2").val()).toFixed(1) == 0.0){
                   $("#subVrtlBlnc").val("");
              }else{
                   $("#subVrtlBlnc").val(0);
              }
     }
          */
          var iMustPay=parseFloat(finalTotalAmount)-parseFloat($("#subVrtlBlnc2").val())-parseFloat($("#subGiftCard2").val());
          iMustPay=iMustPay.toFixed(1);
          <c-rt:if test="${'on' eq useCreditcardPeriod and not empty creditcard and chkAvailableDetails}">
              if ($('input[id=paytype80]').is(":checked") == true && "" !=$("#creditcardDetailId").val() && parseFloat($("#editPeriod").val()) > 0 && parseFloat($("#editPeriodFee").val()) >= 0 ){
                   $("#periodAmount").text(parseFloat(iMustPay * (1+parseFloat($("#editPeriodFee").val()/100))).toFixed(1));
                   $("#periodMoney").text("（每期约"+Math.ceil(parseFloat($("#periodAmount").text())/parseFloat($("#editPeriod").val()))+"元）");
                   $("#finalPeriodMoney1").text("（每期约"+Math.ceil(parseFloat($("#periodAmount").text())/parseFloat($("#editPeriod").val()))+"元）");
                   $("#finalPeriodMoney2").text("（每期约"+Math.ceil(parseFloat($("#periodAmount").text())/parseFloat($("#editPeriod").val()))+"元）");
                   $("#editPeriodAmount").val(parseFloat($("#periodAmount").text() - iMustPay).toFixed(1));
                   iMustPay = parseFloat(iMustPay) + parseFloat($("#editPeriodAmount").val());
                   $("#pFinalTotalAmount").text(parseFloat(finalTotalAmount) + parseFloat($("#editPeriodAmount").val()));//付款方式-订单金额 + 分期手續費
                   $("#pPeriodTotalAmount").text($("#editPeriodAmount").val());
                   $("#showPeriodAmount").show();
              }else{
                   $("#pPeriodTotalAmount").text("");
                   $("#showPeriodAmount").hide();
                   $("#editPeriodAmount").val("0.0");
              }
          </c-rt:if>
          $("#finalMustPay").val(iMustPay);<%--剩余应付金额--%>
          $("#closeFinalTotalAmount").val(iMustPay);     <%--实际应付总金额-订单明细-开启订单明细--%>
          <%--使用禮券付清全額，且無運費、cod手續費--%>
          if ( parseFloat(iMustPay) == 0 && parseFloat($("#pShipFare").text()) == 0 && parseFloat($("#codFee").val()) == 0 &&
                   parseFloat($("#subVrtlBlnc2").val()) == 0 && parseFloat($("#subGiftCard2").val()) == 0 && parseFloat($("#pDiscount").text()) == 0 &&
                   parseFloat($("#pBonus").text()) == 0 && parseFloat($("#pGiftCard").text()) == 0 && parseFloat($("#pVirtualBalance").text()) == 0 && parseFloat($("#pCoupon").text()) > 0 ){
                   $("#allpaymsg").show();
                   $("input[id^='paytype']").each(function(i){
                        if(this.id=='paytype40'){
                             $(this).attr("disabled", false);
                             $(this).attr("checked", true);
                        }else{
                             $(this).attr("disabled", true);
                             $(this).attr("checked", false);
                        }
                   });
          }
          if ( parseFloat(iMustPay) != 0 ){
               if(parseFloat($("#finalTotalAmount").val())>10000 || "${canUseCod}" == "false"){
                   $("#paytype30").attr("disabled",true);
                   $("#paytype30").attr("checked",false);
                   $("#paytypeCash").attr("disabled",true);
                   $("#paytypeCash").attr("checked",false);
                   $("#paytypePos").attr("disabled",true);
                   $("#paytypePos").attr("checked",false);
                   $("#showOrderPriceLimit").html("(订单金额超过10000元，将不提供货到付款服务。)");
                   if ( "${canUseCod}" == "false"){
                        $("#showOrderPriceLimit").html("(订单中有商品不支持货到付款服务。)");
                   }
                   $("#displayPOS").hide();
              }else{
                   var tmpDistrict=$("#district").find('option:selected').text();
                   if(tmpDistrict.substring(0,1)=='※'){
                        $("#paytype30").attr("disabled",false);
                        $("#paytypeCash").attr("disabled",false);
                        $("#paytypePos").attr("disabled",false);
                        $("#showOrderPriceLimit").html("(需加收手续费 ${codFee} 元)");
                        $("#displayPOS").show();    
                   }else{
                        $("#paytype30").attr("disabled",true);
                        $("#paytype30").attr("checked",false);
                        $("#paytypeCash").attr("disabled",true);
                        $("#paytypeCash").attr("checked",false);
                        $("#paytypePos").attr("disabled",true);
                        $("#paytypePos").attr("checked",false);
                        $("#displayPOS").hide();
                   }
              }
              isPos();
              //checkIfDisableCOD('false');
              if ($("#disableCod").val() == "true" ){
                   disableCOD();
              }
          }
     }
     function calcuTotal(sumAmount,shipFare,coupon,bonus){
          var fTotal=0.0;
          fTotal=parseFloat(sumAmount)+parseFloat(shipFare)-parseFloat(coupon)-parseFloat(bonus);
          fTotal =fTotal.toFixed(1);
          return fTotal;
     }
    
          <%--礼券初始化--%>
          function initCoupon(){
              $("#chkCoupon").attr("checked",false);
              $("#chkBonus").attr("checked",false);
              $("#editBonus").val('0.0');
              $("#offset").text("0元");
              $("#editCoupon").val('0.0');
              $("#showCpCode").val("");
              $("#allpaymsg").hide();
              $("#rechkCoupon").hide();
          }

          <%--购物金初始化--%>
          function initBonus(){
              $("#chkCoupon").attr("checked",false);
              $("#chkBonus").attr("checked",false);
              $("#editCoupon").val(0.0);
              $("#showCpCode").val("");
              $("#editBonus").val('0.0');
              $("#offset").text("0元");
          }    

     function initWallet(){
       $("#useWallet").hide();
       $("#subVrtlBlnc").attr("readOnly", true);
       $("#subVrtlBlnc").css("background-color","silver");
       $("#allpaymsg").hide();     
       $("#chkVrtBlnc").attr('checked', false);
       $("#chkVrtBlnc").val(0.0);
           $("#subVrtlBlnc2").val(0.0);
       $("#subVrtlBlnc").val("");
      ProcessCalcuTotal();
       if(parseFloat($("#finalMustPay").val())!=0){
         $("input[id*='paytype']").each(function(i){
           if(this.id=='paytype40'){
             $(this).attr("disabled", true);
             $(this).attr("checked", false);
           }else{
             $(this).attr("disabled", false);
           }
         });
         ProcessCalcuTotal();
       }  
     }

     function initGiftCard(){
       $("#useGiftCard").hide();
       $("#subGiftCard").attr("readOnly", true);
       $("#subGiftCard").css("background-color","silver");
       $("#allpaymsg").hide();     
       $("#chkGiftCard").attr('checked', false);
       $("#chkGiftCard").val(0.0);
           $("#subGiftCard2").val(0.0);
       $("#subGiftCard").val("");
      ProcessCalcuTotal();
      if(parseFloat($("#finalMustPay").val())!=0){
         $("input[id*='paytype']").each(function(i){
            if(this.id=='paytype40'){
              $(this).attr("disabled", true);
              $(this).attr("checked", false);
            }else{
              $(this).attr("disabled", false);
            }
         });
         ProcessCalcuTotal();
       }  
     }   

     <%--商品缺货配送处理初始化--%>
     function initAllowSplit(){
          if ($('input[id=paytype30]').is(":checked") == true){
              $("#allowSplitY").attr("disabled",true); //cod不允许拆单
              $("#allowSplitY").attr("checked",false);
              $("#allowSplitN").attr("checked",true);
              unCheckPeriod();
            checkIfDisableCOD('true');
          }else{
              $("#allowSplitY").attr("disabled",false); //cod不允许拆单
              $("#allowSplitN").attr("disabled",false); //cod不允许拆单
              $("#allowSplitY").attr("checked",false);
              $("#allowSplitN").attr("checked",false);
              unCheckPeriod();
              checkIfDisableCOD('false');          
          }
     }

     <%--付款方式初始化--%>
     function initPaytype(){
          $("input[id^='paytype']").each(function(i){
              $(this).attr("disabled", false);
              $(this).attr("checked", false);
          });
          $("#allpaymsg").hide();
          ProcessCalcuTotal();
     }
    
<c-rt:if test="${campProductWeight!=null}">
<c-rt:set var="totalWeight" value="${campProductWeight}" scope="request"/>
</c-rt:if>
<c-rt:if test="${campProductWeight==null}">
<c-rt:set var="totalWeight" value="0" scope="request"/>
</c-rt:if>
<c-rt:forEach items="${cartOrders.cartOrderProducts}" var="op">
     <c-rt:forEach items="${op.details}" var="opd">
          <c-rt:set var="totalWeight" scope="request">
               ${pu:toFloat(totalWeight)+opd.qty*opd.weight}
          </c-rt:set>
     </c-rt:forEach>
</c-rt:forEach>
<c-rt:set var="totalWeight" value="${pu:toFloat(totalWeight)/1000}" scope="request"/>
     <%--是否耀点100货到付款支援区域(ajax)--%>
     function serviceSupportMessage(service){
     $('#dialog').addClass('ui-dialog-content ui-widget-content COD-area');
     var selProvince = $("#province").find('option:selected').text();
     var selCity = $("#city").find('option:selected').text();
          var selDistrict = $("#district").find('option:selected').val();
          if ( "" != selProvince && "" != selCity && "" != selDistrict && "" != service ){
          var splitDistrict = selDistrict.split(",");
     $.ajax({
              url: '<%=ServerValue.getFrontContextPath()%>/shopping/addressdata/findCartServiceSupport.do',
              type: 'post',
              dataType: 'json',
              data: {id:'${cartOrders.cartId}',province:selProvince,city:selCity,district:splitDistrict[0].replace("※",""),service:service},
              cache: false,
              success: function( actionResult ){
                  if ( "" != actionResult ){
                             var chkPaytype30=$('input[id=paytype30]').is(":checked");
                             var result = actionResult.split("|");
                             if ( chkPaytype30 == true && ("" != result[0] || "undefined" != typeof(result[0]) || "" != result[1]) || "undefined" != typeof(result[1]) ){
                                  var msage="";
                                  msage=msage+"<div class='msgrn'><span class='tips'>请注意：</span><br />您的送货地址属较偏远地区，有可能会超出\"货到付款\" 服务范围。<br />建议选择 \"网上支付\" 可确保商品在最短时间内配达。</div>";
                                  msage=msage+"<table class='tb-p01'>";
                                  msage=msage+"<tr>";
                                  msage=msage+"<th colspan='2'>县区</th>";
                                  msage=msage+"</tr>";
                                  msage=msage+"<tr>";
                                  msage=msage+"<td class='sec-th'>可服务区域</td> ";
                                  msage=msage+"<td>";
                                  if ( "" != result[0] && "undefined" != typeof(result[0])){
                                      msage = msage + result[0];
                                  }
                                  msage=msage+"</td>";
                                  msage=msage+"</tr> ";
                                  msage=msage+"<tr>";
                                  msage=msage+"<td class='sec-th'>不可服务区域</td>";
                                  msage=msage+"<td>";
                                  if ( "" != result[1] && "undefined" != typeof(result[1])){
                                      msage = msage + result[1];
                                  }
                                  msage=msage+"</td>";
                                  msage=msage+"</tr>";
                                  msage=msage+" </table>";
                                  msage=msage+"<table class='ftips'><tr><td colspan='2'>﹡服务区域仅供参考，具体范围以物流公司实际到达范围为准。</td></tr></table>";
                                  alertDialog('耀点100货到付款支援区域', msage,"",600,'auto');
                             }
                  }
                   }
              });
     }
     isPos();
     }   


     function calcPeriodFee(objVal){
          <%--先计算目前订单应付金额--%>
          ProcessCalcuTotal();
          <%--计算分期手续费--%>
          var periodData = objVal.split(',');
          $("#editPeriod").val(periodData[0]);
          $("#editPeriodFee").val(periodData[1]);
          <%--加上分期手续费再算一次--%>
          ProcessCalcuTotal();
          $("#periodAmountDiv").show();
     }
    
     var isGoNext=false;

     function caleShipFare(tmpProvince,isBuyNowFlag,tmpFinalMustPay,addCmpPd,buyNowCartId){
          $.post("<%=ServerValue.getFrontContextPath()%>/shopping/orderInfo/getFreight.do",{codProvince:tmpProvince,isBuyNow:isBuyNowFlag,finalMustPay:tmpFinalMustPay,addCmpPd:addCmpPd,buyNowCartId:buyNowCartId},callback,"json");
          function callback(result){
              $("#spanFreight").text(result);
               $("#editShipFare").val(parseFloat(result).toFixed(1));
              ProcessCalcuTotal();
          }   
     }
     <%--去除字串左邊的空白虛格--%>
     function ltrim(instr){
     return instr.replace(/^[\s]*/gi,"");
     }

     <%--去除字串右邊的空白虛格--%>
     function rtrim(instr){
          return instr.replace(/[\s]*$/gi,"");
     }

     <%--去除字串前後的空白虛格--%>
     function trim(instr){
          instr = ltrim(instr);
          instr = rtrim(instr);
          return instr;
     }

     <%--查詢province ajax--%>
     function queryProvince2(adCity,adDistrict){
          var province=$("#province").find('option:selected').val();
          if ( "" != province ){
              $.ajax({
              url: '<%=ServerValue.getFrontContextPath()%>/shopping/addressdata/findCartCitys.do',
              type: 'post',
              dataType: 'json',
              data: {id:'${cartOrders.cartId}',province:province},
              cache: false,
              beforeSend: function(xhr) {
               var options = '<option value="">资料载入中...</option>';
               $("#city").html(options);
          },
              success: function( actionResult ){
                   addressObj(actionResult,'CITY',adCity,adDistrict);
                   }
              });
          }
     }
    
     <%--查詢city ajax--%>
     function queryCity2(adDistrict){
          var city=$("#city").find('option:selected').val();
          $.ajax({
         url: '<%=ServerValue.getFrontContextPath()%>/shopping/addressdata/findCartDistrictsCod.do',
         type: 'post',
         dataType: 'json',
         data: {id:'${cartOrders.cartId}',city:city},
         cache: false,
         beforeSend: function(xhr) {
          var options = '<option value="">== 选择地区 ==</option>';
                   $("#district").html(options);
     },
         success: function( actionResult ){
              addressObj(actionResult,'DISTRICT','',adDistrict);
              }
          });
     }

     <%--Province&City 查詢元件--%>
     function addressObj(actionResult,execObj,adCity,adDistrict){
          if(actionResult!=null ){
              var arr_text = actionResult.split("$");         
              if(execObj=='CITY'){                                    
                   var options = '<option value="">== 选择城市 ==</option>';
              }
              if(execObj=='DISTRICT'){
                   var options = '<option value="">== 选择地区 ==</option>';
              }
              for(i=0;i<arr_text.length;i++){
                   v=arr_text[i].split(",");
                   if(execObj=='CITY'){   
                        options += '<option value="' + v[1] + '">' + v[1] + '</option>';
                   }
                   if(execObj=='DISTRICT'){
                        options += '<option value="' + v[1]+','+v[2]+','+v[3] +','+v[4] + '">' + v[1] + '</option>';
                   }
              }
              var aObj;
              if(execObj=='CITY'){   
                   $("#city").html(options);
                   aObj=$("#city");
              }
              if(execObj=='DISTRICT'){
                   $("#district").html(options);
                   aObj=$("#district");
              }
              aObj[0].selectedIndex = 0 ;
              var tmpObj;
              if(execObj=='CITY'){   
                   tmpObj=adCity;
              }
              if(execObj=='DISTRICT'){
                   tmpObj=adDistrict;
              }
              if(tmpObj !=""){
                   aObj.children().each(function(index){
                        if(execObj=='CITY'){   
                             if ($(this).text()==adCity){
                                  setTimeout(function() {  aObj[0].selectedIndex = index ;
                                  queryCity2(adDistrict);} , 1);
                             }
                        }
                        if(execObj=='DISTRICT'){
                             if ($(this).text().substring(1)==adDistrict || $(this).text()==adDistrict){
                                  setTimeout(function() {  $("#district")[0].selectedIndex = index ;
                                  queryDistinct();},1);
                             }
                        }
                   });
              }
          }
     }

     <%--查詢distinct ajax--%>
     function queryDistinct(){
          var districtVal = $("#district").find('option:selected').val();
          var districtTxt = $("#district").find('option:selected').text();
          var dtVal=districtVal.split(",");
          //if(districtTxt.substring(0,1)=='※' && dtVal[2]!='' && dtVal[3]!=''){
                   //alert('可服務區域：'+dtVal[2]+',不可服務區域：'+dtVal[3]);
          //}
          if(districtTxt.substring(0,1)=='※'){
              //startDistrict=startDistrict.substring(1);
               if(parseFloat($("#finalTotalAmount").val())>10000 ||  "${canUseCod}" == "false"){
                   $("#paytype30").attr("disabled",true);
                   $("#paytypeCash").attr("disabled",true);
                   $("#paytypePos").attr("disabled",true);
                   $("#showOrderPriceLimit").html("(订单金额超过10000元，将不提供货到付款服务。)");
                   if ( "${canUseCod}" == "false" ){
                        $("#showOrderPriceLimit").html("(订单中有商品不支持货到付款服务。)");
                   }
                   $("#displayPOS").hide();
              }else{
                   $("#paytype30").attr("disabled",false);
                   $("#paytypeCash").attr("disabled",false);
                   $("#paytypePos").attr("disabled",false);
                   $("#displayPOS").show();
              }
              $("#version").val(dtVal[2]);
          }
          isPos();
     }
    

     <%--判斷是否使用POS--%>
     function isPos(){
          var tmpDistrictVal=$("#district").find('option:selected').val();
          var dtVal=tmpDistrictVal.split(",");
          if(dtVal[1]=='N'){
              $("#paytypePos").attr("disabled",true);
              $("#posMessage").html("<span class='txt-rd'>(此服务目前仅支援上海地区)</span>");
          }else{
              $("#posMessage").html("");
          }   
          chkTotalAmountOverThousand();
     }

     <%--upcheck 分期付款--%>
     function unCheckPeriod(){
          if ( !$('input[id=paytype80]').is(":checked") ){
               $("#creditcardDetailId").attr("selectedIndex",0);
              $("#periodDiv").hide();
              $("#periodSpan").hide();
              $("#periodSpan").text("");
              $("#periodAmountDiv").hide();
              $("#periodAmount").text("0.0");
              $("#periodMoney").text("");
              $("#finalPeriodMoney1").text("");
              $("#finalPeriodMoney2").text("");
              $("#editPeriod").val("");
          }
     }
    
     <%--upcheck POS cash & pos--%>
     function unCheckPos(){
          if ( "${canUseCod}" == "false" ){
              $("#displayPOS").hide();
          }   
          $("#paytypeCash").attr("checked",false);
          $("#paytypePos").attr("checked",false);   

          if ($("#disableCod").val() == "true" ){
              disableCOD();
          }
     }

     <%--disable COD--%>
     function disableCOD(){
          $("#paytype30").attr("disabled",true);
          $("#paytype30").attr("checked",false);
          $("#paytypeCash").attr("disabled",true);
          $("#paytypeCash").attr("checked",false);
          $("#paytypePos").attr("disabled",true);
          $("#paytypePos").attr("checked",false);
          $("#displayPOS").hide();
     }

     <%--check if disable COD--%>
     function checkIfDisableCOD(showAlert){
    $.post("<%=ServerValue.getFrontContextPath()%>/shopping/orderInfo/isCodForBadOrder.do",{addr:$('#addr').val(),mobile:$('#mobile').val(),phone:$('#phone').val()},
              function callback(result){
                   if(result.indexOf('异常')>0){
                        if(showAlert=='true'){
                        alert("该订单超过货到付款使用限制，请改使用其他支付方式");
                        disableCOD();
                        }
                        if(result.split(",")[1]=='true'){
                             $("#disableCod").val('true');
                        }else{
                             $("#disableCod").val('false');
                        }
                   }else{
                        $("#disableCod").val('false');
                        if ( $('input[id=paytype30]').is(":checked") || $('input[id=paytypeCash]').is(":checked") || $('input[id=paytypePos]').is(":checked") ){
                             if(trim($("#mobile").val())==""){
                        alertDialog('填手机号码', '选择货到付款必须填手机号码',"",350,120);
                    }
                        }
                   }
                   setTimeout(ProcessCalcuTotal,1);
              },
              "json");
     }

     function chkTotalAmountOverThousand(){
          if(parseFloat($("#editTotalAmount").val())>10000){
              $("#paytype30").attr("disabled",true);
              $("#paytypeCash").attr("disabled",true);
              $("#paytypePos").attr("disabled",true);
              $("#showOrderPriceLimit").html("(订单金额超过10000元，将不提供货到付款服务。)");
              $("#displayPOS").hide();
          }
          <c:if test="${fn:length(cartOrders.joinOrderSupplySet)>1}"><%-- 拆单数大于一, 暂停 COD --%>
              $("#paytype30").attr("disabled",true);
              $("#paytypeCash").attr("disabled",true);
              $("#paytypePos").attr("disabled",true);
              $("#showOrderPriceLimit").html("(订单含有合并结帐商品，将不提供货到付款服务。)");
              $("#displayPOS").hide();
          </c:if>
     }
     function numberCount(word){
    var length=0;
    for(var cc=0;cc<word.length;cc++){
       var c = word.charCodeAt(cc);
      if ((c>=48&&c<=57)) length++;
    }
    return length;
     }
     function chineseCount(word){
    var length=0;
    for(var cc=0;cc<word.length;cc++){
       var c = word.charCodeAt(cc);
      if (!(c>=32&&c<=126)) length++;
    }
    return length;
     }
</script>
<s:form action="paymentInfo/paymentInfo.do" id="paymentInfoForm" name="paymentInfoForm" method="post">
     <c-rt:if test="${isBuyNow=='true'}">
          <input type="hidden" id="buyNowCartId" name="buyNowCartId" value="${cartOrders.cartId}"/>
     </c-rt:if>
     <div id="container">   
          <div id="main">
          <div class="order-step"><img src="/images/orderstep_2.gif" alt="订购步骤2_填写订购信息" /></div>
          <div class="payment">
     <!-- 收货人 -->
      <h3>收货人信息 <span><a href="#" id="myAddBook">从收货地址簿选取</a></span><span>(<b class="txt-rd">*</b>为必填项目)</span></h3>
      <div class="consignee">
        <ul>
          <li class="w-1of1"><label for="name"><span class="txt-rd">*</span> 姓    名：</label><span>   
               <input type="text"  class="txt-gy" name="contactName" id="contactName" value="${lastAddressBook.contactName}" maxlength="20" size="15"/><br/>
               <span id="contactNameTip" class="msg rn" style="display:block;">请填写收货人</span>
               </span>
          </li>
                <li class="w-1of1">
          <div><label><span class="txt-rd">*</span> 地    址：</label></div>
          <div>省份： 
                             <select class="c-prov" name="province" id="province">
                                  <option value="">== 选择省 ==</option>
                                  <c-rt:forEach items="${provincesMap}" var="province">
                                      <option value="${province.key}">${province.key}</option>
                                  </c-rt:forEach>
                             </select>
                             市：
                             <select id="city" name="city">
                                  <option value="">== 选择城市 ==</option>
                             </select> 区：
                             <select id="district" name="district">
                                  <option value="">== 选择地区 ==</option>
                             </select>
              <br/>
                  <span id="provinceTip" class="msg rn"></span><br/>
               <p class="txt-gy">※号代表货到付款支持区域，具体服务范围以物流公司可实际到达范围为准。</p>
              <br />
      <c-rt:if test="${not empty prodVolumeMap}">
           <p class="bigsize-txt">
               <strong>提醒您：</strong>订购的部份商品为<span class="txt-rd">大材积</span>，仅显示该商品能配送到达的地址。<a href="javascript:;" id="showProdVolume">查看大材积商品</a>
           </p>
                   <ul style="display:none;" id="arriveplace">
             <s id="prodVolumeClose">X</s>
             <c-rt:forEach items="${prodVolumeMap}" var="prod">
               <li>${prod.value}</li>
             </c-rt:forEach>
           </ul>
      </c-rt:if>
                      邮编： <input type="text" name="zipCode" id="zipCode" value="${lastAddressBook.zipCode}" size="6" maxlength="6"/>
                  街道： <input size="50" class="txt-gy" type="text" name="addr" id="addr" value="${lastAddressBook.addr}" /><br/>
                  <span id="addrTip" class="msg rn"></span>
                  </div>             
              </li>
              <li class="c-f">
                <label for="tel"><span  class="txt-rd">*</span>固定电话：</label>              
                <span>
                <input type="text" name="areaCode" id="areaCode" value="${lastAddressBook.areaCode}" size="5" maxlength="4"/>-
              <input type="text" name="phone" id="phone" value="${lastAddressBook.phone}" size="10" maxlength="10" maxlength="8"/>- 分机
                   <input type="text" name="extension" id="extension" value="${lastAddressBook.extension}" size="4" maxlength="8"/>
                </span>&nbsp;<strong><span  class="txt-rd">*</span>手机号码：</strong>
                <input type="text" name="mobile" id="mobile"  value="${lastAddressBook.mobile}" size="18" maxlength="11"/>
                <span class="txt-ss">&nbsp;(<span  class="txt-rd">*</span>固定电话与手机需至少填写一区)</span>
                <br/>
                <span id="telTip" class="msg rn">请至少填写一组电话</span>
                </li>
             <li class="c-f">
             <c-rt:if test="${member.email=='xx'}">
                 <label for="tel"><span class="txt-rd">*</span>联络邮箱：</label>
                     <input id="mail" name="mail" value="" size="50" >
                     <span class="txt-ss">&nbsp;(您将会透过此邮箱接收订单进度通知信)</span>
                     <br/>
              <span id="mailTip" class="msg rn" style="display:block;">请填联络邮箱</span></li>
             </c-rt:if> 
              <c-rt:if test="${member.email!='xx'}">
              <input id="mail" name="mail" value="${member.email}" type="hidden" size="50" >
               </c-rt:if>
             <!-- 
               <div><label>备    注：</label></div>
              <div>
              <textarea cols="25" rows="4" class="txt-gy" id="memo" name="memo"></textarea>          
              </div>
               -->                 
           </ul>
        </div>
        <!-- 配送方式 -->
                   <h3>送货方式與运费说明</h3>
                   <div class="send-way">
                        <ul>
                             <li class="w-1of3"><strong>运送方式：</strong>一般快递或EMS邮政快递</li>
                             <li class="w-1of5"><strong>运费：<span class="txt-rd"><span id="spanFreight">0</span>元</span></strong>(重量总计<fmt-rt:formatNumber value="${totalWeight }" pattern="0.###"/>kg，<a href="#" id=payPortage>查看运费计算方式</a>)<br />
                                 <c:if test="${!empty campaignDiscount.orderinfoHtml}">
                                       <br /><br /><p class="no-portage">${campaignDiscount.orderinfoHtml}</p>
                 </c:if>
            </li>
          </ul>
          </div>
        <!-- 優惠方式 -->
          <h3>优惠折扣<c-rt:if test="${discountType eq 'single'}"><span>(礼券或积分，请择一使用)</span></c-rt:if></h3>
        <div class="discount-way">
          <ul>
            <li class="w-1of1"><c-rt:if test="${discountType ne 'single'}"><strong>可选择多项：</strong></c-rt:if>
            <input type="hidden" id="showCpCode" name="couponInfo" value=""/>
            <input id="chkCoupon" name="chkCoupon" type="checkbox" value=""> 折扣礼券 (<a href="javascript:;" id="rechkCoupon" style="display:none;">重新选择礼券 |</a>  <a href="/help/3_coupons.html" target="_blank">礼券使用说明</a>)</li>
            <li class="w-1of1 pad-1">
            <c:if test="${overOneThousand=='N'}">
            <input id="chkBonus" name="chkBonus" type="checkbox" value="">
            使用 <span id="offsetBonus">0</span> 积分折抵<strong class="txt-rd" id="offset">0.0</strong> 元 / 目前共有 <strong class="txt-rd">${member.balance.bonusBalance}</strong> 积分（目 前${bonusCampaign.offsetRate} 积分可折抵 1 元，详见
            <a href="/help/3_coin.html#rule" target="_blank">积分使用说明</a> |
            <a href="/help/3_coin.html#conversion" target="_blank">购物金积分转换说明</a>。）
            <input type="hidden" name="canUse" id="canUse" value="${canUse}">
            </c:if>
            <c:if test="${overOneThousand=='Y'}">
            本日已超过1000元购物金，无法使用购物金
            </c:if>
            </li>
          </ul>
         </div>
        <!-- 付款方式 -->
        <h3>付款方式<span><img src="/images/icon_cart_360.gif" style="vertical-align:text-top" />与耀点100共同保护您的帐户安全</span></h3>
        
       <div class="pay-way">
           <ul>
           <li class="w-1of1 pad-1"><input id="chkGiftCard" name="chkGiftCard" type="checkbox" value="0.0"> 用我的礼品卡
              <input size="8" id="subGiftCard" name="subGiftCard"  value="" class="txt-rd" style="background-color:silver" readOnly />
                   元来支付 / 目前我的礼品卡余额为<strong>￥<span id="myGiftCardBalance">${member.balance.giftcardBalance}</span>元</strong>
                 <span id="useGiftCard" style="display:none;"><input type="button" id="confirmGiftCard" value="确认使用" name=""></span>
                </li>
           <li class="w-1of1 pad-1"><input id="chkVrtBlnc" name="chkVrtBlnc" type="checkbox" value="0.0"> 用我的帐户余额
               <input size="8" id="subVrtlBlnc" name="subVrtlBlnc"  value="" class="txt-rd" style="background-color:silver" readOnly />
                   元来支付/目前我的帐户余额为<strong>￥<span id="myVirtualBalance">${member.balance.virtualBalance}</span>元</strong>
               <span id="useWallet" style="display:none;"><input type="button" id="confirmWallet" value="确认使用"/></span>
             </li>
             <li class="w-1of1 pad">订单金额：
               <strong class="txt-rd">￥ <span id="pFinalTotalAmount"></span> 元</strong>
               (＝商品合计金额<strong> <span id="pTotalAmount"></span> 元</strong> + 运费<span id="pShipFare"></span>元+ 货到付款手续费<span id="codFee2" >0.0</span>元 - 礼券<span id="pCoupon"></span>元 - <span id="pOffsetBonus">0</span>积分折抵<span id="pBonus"></span>元 - 折扣<span id="pDiscount"></span>元
               <span id="showPeriodAmount" style="display:none;"> + 分期手续费<span id="pPeriodTotalAmount"></span> 元</span> - 礼品卡<span id="pGiftCard">0.0</span>元 - 帐户余额<span id="pVirtualBalance">0.0</span>元 )              
           </li>
           <li class="w-1of1 cut-line">&nbsp;</li>
           <li class="w-pay"><strong>请选择付款方式：</strong>
              <div style="display:none;"><input id="paytype40" name="paytype" type="radio" value="40">  <strong>全额由我的帐户余额或礼券付清</strong></div>
              <div id="allpaymsg" style="display:none;"><strong class="txt-rd">本订单已由「帐户余额/礼品卡」付清全额，您不需再选择付款方式。</strong></div>
                    <div><input id="paytype50" name="paytype" type="radio" value="50">  <strong>网上支付</strong></div>
                    <div><p>支持以下银行借记卡及信用卡，需开通网银：</p></div>
              <div id="paytype_paytype50_1"><p><strong>银行支付：</strong></p></div>
              <div id="paytype_paytype50_2"><span class="sub-bank"><img src="/images/payment_banks.gif" alt="银行支付" /></span></div>
              <div><p><strong>第三方支付：</strong></p></div>
              <div><span class="sub-bank">
                                      <c:if test="${member.applySource eq 'taobaomember' or member.applySource eq 'alipaymember'}">
                        <img src="/images/payment_thirdparty_taobao.gif" alt="第三方支付" />
                                      </c:if>
                                      <c:if test="${member.applySource ne 'taobaomember' and member.applySource ne 'alipaymember'}">
                        <img src="/images/payment_thirdparty.gif" alt="第三方支付" />
                                      </c:if>
               </span>
             </div>
             <c-rt:if test="${'on' eq useCreditcard}">
             <div id="paytype_paytype70"><input type="radio" id="paytype70" name="paytype" value="70"> <strong>信用卡单期支付</strong></div>
             <div><p>支持以下银行信用卡单期直付，无需开通网银：</p></div>
             <div><span class="sub-bank"><img alt="信用卡单期支付银行" src="/images/payment_card_single.gif"></span></div>
             </c-rt:if>
             <c-rt:if test="${'on' eq useCreditcardPeriod and not empty creditcard and chkAvailableDetails}">
              <div id="paytype_paytype80"><input type="radio" id="paytype80" name="paytype" value="80"> <strong>信用卡分期支付</strong></div>
              <div>
                        <p>发卡银行：<label>
                        <select id="creditcardDetailId" name="creditcardDetailId">
                            <option value="">请选择</option>
                            <c-rt:forEach items="${creditcard.cardDetails}" var="cardDetail">
                                            <c-rt:choose>
                                                <c-rt:when test="${cardDetail.setting.creditcardName eq '快钱'}">
                                                     <c-rt:forEach items="${billBankCodeMenu.options}" var="bankCode">
                                           <option value="${cardDetail.id}">${bankCode.value.name}</option>
                                      </c-rt:forEach>
                                  </c-rt:when>
                                  <c-rt:otherwise>
                                      <option value="${cardDetail.id}">${cardDetail.setting.creditcardName}</option>
                                  </c-rt:otherwise>
                             </c-rt:choose>
                            </c-rt:forEach>
                          </select>
                        </label></p>
                   </div>
                   <div id="periodDiv">
                        <p>分期期数：
                             <span id="periodSpan"></span>
                        </p>
                   </div>
                   <div id="periodAmountDiv"><p>分期总额：<strong class="txt-L txt-rd" id="periodAmount">0.0</strong>元<span class="txt-rd"><strong id="periodMoney"></strong></span></p></div>
               </c-rt:if>             
               <div id="paytype_paytype20"><input type="radio" id="paytype20" name="paytype" value="20"> <strong>邮局汇款</strong> <span class="txt-gy">(至邮局柜台汇款)</span></div>
               <div id="paytype_paytype10"><input id="paytype10" name="paytype" type="radio" value="10"> <strong>银行转帐</strong> <span class="txt-gy">(至银行柜台汇款)</span></div>
               <div id="paytype_paytype30"><input id="paytype30" name="paytype" type="radio" value="">  <strong>货到付款</strong> <span class="txt-gy"></span><span class="txt-rd"><strong id="showOrderPriceLimit" >(需加收手续费 ${codFee}元)</strong></span>
                        <div id="displayPOS">
                                      <div><p><input id="paytypeCash" name="paytypecp" type="radio" value="30" />
                                      现金</p></div>
                                      <div><p><input id="paytypePos" name="paytypecp" type="radio" value="60" />
                                      POS机刷卡<strong id="posMessage"></strong></p></div>
                   </div>
                   <input type="hidden" id="disableCod" name="disableCod" value=""/>
               </div>
                                      <c:if test="${member.applySource eq 'taobaomember'}">
                                           <script>
                                                $("#paytype_paytype20").hide();
                                                $("#paytype_paytype10").hide();
                                                $("#paytype_paytype30").hide();
                                                $("#paytype_paytype50_1").hide();
                                                $("#paytype_paytype50_2").hide();
                                                $("#paytype_paytype70").hide();
                                                $("#paytype_paytype80").hide();
                                           </script>
                                      </c:if>
           </ul>
      </div>
     <!-- START 商品缺货配送处理方法 -->
     <c:if test="${fn:length(cartOrders.cartOrderProducts)>1}"><%-- 提供选择是否允许拆单 --%>
     <h3>商品缺货配送处理方法</h3>
     <div class="discount-way">
          <ul>
              <li class="w-1of1"><label><input name="allowSplit" type="radio" id="allowSplitY" value="Y"/> <strong>有货先发</strong>（若订单中部分商品缺货，优先配送有货商品，订单将会被拆分成多张订单，总订单金额不变，<span class="txt-rd">不支持货到付款</span>）</label></li>
              <li class="w-1of1 pad"><label><input name="allowSplit" type="radio" id="allowSplitN" value="N"/> <strong>货齐再发</strong>（若订单中部分商品缺货，则会等到商品补齐再配送）</label></li>
          </ul>
     </div>
     </c:if>
     <!-- END 商品缺货配送处理方法 -->
       <!-- 发票信息 -->
          <h3>发票信息</h3>
       <div class="pay-way">
           <ul>
                <li class="w-pay">
                <strong>发票：
                             <input id="invotype01" name="invotype" type="radio" value="01">  <strong>个人</strong>
                             <input id="invotype02" name="invotype" type="radio" value="02">  <strong>单位</strong>
                             <input size="20" type="text" name="invoTitle" id="invoTitle" value="" maxlength="40"/>
                </strong>
           </ul>
            <div class="paymentinvoice">
                <span class="txt-gy">
                           <p>注:普通发票因商品而异，随货寄送或于订单签收后10个工作日寄出。</p>
                           <p>  企业客户若需增值税专用发票，<a href="/help/7_invoice.html" target="_blank">请向客服申请开具增值税发票。</a></p>
                 </span>
            </div>
      </div>
       <!-- 訂單明細close -->
       <div id="orderCartDetailClose">     
      <h3>订单明细<a id="orderCartToggleCloseName" href="javascript:;" class="a-more a-blue">开启订单明细</a></h3>
        <div  class="od-detail">
          <p class="total-1">本次订购共<span class="txt-rd">${cartOrders.productSum}</span> 项商品，实际应付总金额：
          <span class="txt-rd">￥<input type="text" id="closeFinalTotalAmount" value=""  class="show-money txt-L" readonly="true" size="14">元</span></p>
          <p class="total-1"><span class="txt-rd"><strong id="finalPeriodMoney1"></strong></span></p>
          </div>       
          </div>
        <!-- 訂單明細 -->   
      <c-rt:set var="campaigns" value=""/>
    <c-rt:forEach items="${cartOrders.applyCampaign }" var="campaign">
     <c-rt:if test="${!empty campaigns}">
     <c-rt:set var="campaigns">
     ${campaigns },${campaign.key }
     </c-rt:set>
     </c-rt:if>
     <c-rt:if test="${empty campaigns}">
     <c-rt:set var="campaigns">
     ${campaign.key }
     </c-rt:set>
     </c-rt:if>
    </c-rt:forEach>
    <input type="hidden" name="campaigns" value="${campaigns}"/>
        <!-- 訂單明細open-->
         <div id="orderCartDetailOpen">
      <h3>订单明细<a id="orderCartToggleOpenName" href="javascript:;" class="a-more a-blue">关闭订单明细</a><a name="detail"></a></h3>
          <div class="od-detail d-show">
         <table class="tb-3">
             <thead>
               <tr>
                 <th width="430">商品名称</th>
                 <th width="80">类型</th>
                 <th width="100">属性</th>
                 <th width="70">单价</th>
                 <th width="50">数量</th>
                 <th width="65">小计</th>
               </tr>
             </thead>
             <tbody>
           
              <c-rt:forEach items="${cartOrders.cartOrderProducts }" var="op" varStatus="opStatus">
              
               <c-rt:if test="${op.prodTp=='2'}">
                    <tr>
                   <td colspan="5" align="left" class="table-in">
                        <table border="0">
                        <tr>
                            <td width="430"><p>${op.prodName}</p></td>
                            <td width="80"><span class="type-2">赠品</span></td>
                            <td width="100">${op.prodSpecName}</td>
                            <td width="70" class="txt-price">￥ ${pu:rmb(op.amount)}</td>
                            <td width="50">${op.qty}</td>
                          </tr>
                     </table>
                      </td>
                   <td align="left" class="txt-price">￥ ${pu:rmb(op.totalPrice)}</td>
                   <input type="hidden" id="editAmount_${rows_index.count}" value="${op.totalPrice}"/>
                   </tr>
               </c-rt:if>
                             <c-rt:if test="${op.prodTp=='6'}">
                   <tr>
                   <td colspan="5" align="left" class="table-in">
                        <table border="0">
                        <tr>
                            <td width="430"><p>${op.prodName}</p>
                             <c-rt:if test="${op.prodId==timeLimitCartOrderProductList[0]}">
                                      <p><span class="type-7">秒杀</span> 限时秒杀限会员购买</p>
                                     </c-rt:if>
                            <c-rt:forEach items="${cartOrders.cartOrderProducts}" var="cop" varStatus="status1">
                   <c-rt:if test="${op.cartOrderProdId eq cop.cartOrderProdId}">
                  

                   <c-rt:forEach items="${cop.applyCampaign}" var="ac" varStatus="status2">
                  
                   <p>
                   <c-rt:if test="${ac.active}">
                        <span class="type-4">优惠</span>
                   </c-rt:if>
                   <c-rt:if test="${!ac.active}">
                        <span class="type-6">优惠</span>
                        <c-rt:if test="${ac.campaign.typeExtends[0].minQty-ac.sumQty >= 0}">
                        （尚差${ac.campaign.typeExtends[0].minQty-ac.sumQty}件）
                        </c-rt:if><c-rt:if test="${ac.campaign.typeExtends[0].minQty-ac.sumQty < 0}">
                        （尚差${ac.campaign.typeExtends[0].minOrderAmount-ac.sumAmount}元）
                        </c-rt:if>
                   </c-rt:if>
                   ${pu:reqSet('pc', ac.campaign) }
                   <a class="btn-promo" href="javascript:openCampaign_${status1.index }_${status2.index }()">${ac.campaign.campaignName } </a>
             
                   <script>
                   <c-rt:set scope="request" var="campaignDetail">
              ${pu:replaceAll(pc.campaignDetail, '\'', '&#39;')}
              </c-rt:set>
              <c-rt:set scope="request" var="campaignDesc">
              ${pu:replaceAll(pc.campaignDesc, '\'', '&#39;')}
              </c-rt:set>
                        function openCampaign_${status1.index }_${status2.index }(){
                             var dialogId='dialog';
                             <%
                             String campaignDetail=(String)request.getAttribute("campaignDetail");
                             String campaignDesc=(String)request.getAttribute("campaignDesc");
                             campaignDetail=campaignDetail.replaceAll("\r\n", "").replaceAll("\r", "").replaceAll("\n", "");
                             campaignDesc=campaignDesc.replaceAll("\r\n", "").replaceAll("\r", "").replaceAll("\n", "");
                             request.setAttribute("campaignDetail", campaignDetail);
                             request.setAttribute("campaignDesc", campaignDesc);
                             %>
                             title='活动信息';
                             campaignTitle='${pu:replaceAll(pc.campaignName, '\'', '&#39;')}';
                             desc= '${campaignDesc}';
                             detail='${campaignDetail}';
                             startDate= '<fmt-rt:formatDate value="${pc.startDateTime}" pattern="yyyy/MM/dd HH:mm:ss"/>';
                             endDate= '<fmt-rt:formatDate value="${pc.endDateTime}" pattern="yyyy/MM/dd HH:mm:ss"/>';
                             url= '${pc.campaignUrl}';
                             width= 300;
                             height= 'auto';

                             var content=compositeCampaign(campaignTitle, desc, detail, startDate, endDate, url);
                             openDialog(title, content,width,height);
                             $( '#'+dialogId).dialog('option', 'position', 'top' );
                        }
                   </script>
                   </p>
                   </c-rt:forEach>

                   </c-rt:if>
               </c-rt:forEach>
                            </td>
                            <td width="80">
                                            <c-rt:if test="${op.prodId!=timeLimitCartOrderProductList[0]}">
                                                <c-rt:if test="${op.prodTp == '6'}">
                                                     <span class="type-0">主商品</span>
                                                    </c-rt:if>   
                                               </c-rt:if>
                                             <c-rt:if test="${op.prodId==timeLimitCartOrderProductList[0]}">
                                                <!--<span class="type-1">限购</span>-->
                                               </c-rt:if>
                            </td>
                            <td width="100">&nbsp;</td>
                            <td width="70" class="txt-price">￥ ${pu:rmb(op.amount)}</td>
                            <td width="50">1</td>
                          </tr>
                          <c-rt:forEach items="${op.details}" var="opd">
                             <c-rt:if test="${opd.detailTp == '6' and opd.prodId ne op.prodId}">
                                 <tr>
                                     <td width="430" class="txt-gy"><p>${opd.prodName}</p></td>
                                     <td width="80"><span class="type-4">活动</span></td>
                                     <td width="100" class="txt-gy">${opd.prodSpecName}</td>
                                     <td width="70">&nbsp;</td>
                                     <td  width="50" class="txt-gy">${opd.qty}</td>
                                 </tr>
                                  <c-rt:set var="addOnSum">0</c-rt:set>
                             </c-rt:if>
                        </c-rt:forEach>
                     </table>
                      </td>
                   <td align="left" class="txt-price">￥ ${pu:rmb(op.totalPrice)}</td>
                   <input type="hidden" id="editAmount_${rows_index.count}"  value="${op.totalPrice}"/>
                   </tr>
              </c-rt:if>
              <c-rt:if test="${op.prodTp=='0' or op.prodTp=='1' || op.prodTp == '7'}">
                   <tr>
                      <td colspan="5" align="left" class="table-in">
                        <c-rt:forEach items="${op.details}" var="opd">
                               <table border="0">
                                 <c-rt:if test="${opd.detailTp == '0' or opd.detailTp == '1' or opd.detailTp == '7'}">
                                   <tr>
                                     <td width="430">
                                          <p>${opd.prodName} </p>
                                          <c-rt:if test="${op.prodId==timeLimitCartOrderProductList[0]}">
                                           <p><span class="type-7">秒杀</span> 限时秒杀限会员购买 </p>
                                          </c-rt:if>
                                  
                                     </td>
                                     <td width="80">
                                           <c-rt:if test="${op.prodTp == '0' || op.prodTp == '7'}">
                                                <c-rt:if test="${op.prodId!=timeLimitCartOrderProductList[0]}">
                                                     <c-rt:if test="${op.prodTp == '0' || op.prodTp == '7'}">
                                                          <span class="type-0">主商品</span>
                                                         </c-rt:if>   
                                                    </c-rt:if>
                                                  <c-rt:if test="${op.prodId==timeLimitCartOrderProductList[0]}">
                                                         <!--<span class="type-1">限购</span>-->
                                                    </c-rt:if>
                                           </c-rt:if>
                                           <c-rt:if test="${op.prodTp == '1'}">
                                                <span class="type-1">预购</span>
                                           </c-rt:if>
                                     </td>
                                     <td width="100">${opd.prodSpecName}</td>
                                     <td width="70" class="txt-price">￥ ${pu:rmb(opd.amount)}</td>
                                     <td width="50">${opd.qty}</td>
                                   </tr>
                                   <input type="hidden" id="editAmount_${rows_index.count}"  value="${opd.amount*opd.qty}"/>
                                     <c-rt:set var="addOnSum">0</c-rt:set>
                                  </c-rt:if>
                                  <c-rt:if test="${opd.detailTp == '2'}">
                                      <tr>
                                     <td width="430" class="txt-gy"><p>${opd.prodName}</p></td>
                                     <td width="80"><span class="type-2">赠品</span></td>
                                     <td width="100" class="txt-gy">&nbsp;</td>
                                     <td width="70" class="txt-price">&nbsp;</td>
                                     <td width="50" class="txt-gy">${opd.qty}</td>
                                      </tr>
                                       <c-rt:set var="addOnSum">0</c-rt:set>
                                  </c-rt:if>
                                  <c-rt:if test="${opd.detailTp == '3'}">
                                      <tr>
                                     <td width="430" class="txt-gy"><p>${opd.prodName}</p></td>
                                     <td width="80"><span class="type-3">加购</span></td>
                                     <td width="100" class="txt-gy">${opd.prodSpecName}</td>
                                     <td width="70" class="txt-price">￥ ${pu:rmb(opd.amount)}</td>
                                     <td width="50" class="txt-gy">${opd.qty}</td>
                                     <input type="hidden" id="editAmount_${rows_index.count}"  value="${opd.amount*opd.qty}"/>
                                     <c-rt:set var="addOnSum">${addOnSum + (opd.amount*opd.qty)}</c-rt:set>
                                 </tr>
                                  </c-rt:if>
                               </table>
                             
                               <c-rt:if test="${opd.detailTp ne '2' && opd.detailTp ne '3'}">
                                           <c-rt:forEach items="${cartOrders.cartOrderProducts}" var="cop" varStatus="status1">
                   <c-rt:if test="${opd.prodSpecId eq cop.prodSpecId}">
                  

                   <c-rt:forEach items="${cop.applyCampaign}" var="ac" varStatus="status2">
                  
                   <table border="0">
                    <tr>
                                     <td width="735">
                   <p>
                   <c-rt:if test="${ac.active}">
                        <span class="type-4">优惠</span>
                   </c-rt:if>
                   <c-rt:if test="${!ac.active}">
                        <span class="type-6">优惠</span>
                        <c-rt:if test="${ac.campaign.typeExtends[0].minQty-ac.sumQty >= 0}">
                        （尚差${ac.campaign.typeExtends[0].minQty-ac.sumQty}件）
                        </c-rt:if><c-rt:if test="${ac.campaign.typeExtends[0].minQty-ac.sumQty < 0}">
                        （尚差${ac.campaign.typeExtends[0].minOrderAmount-ac.sumAmount}元）
                        </c-rt:if>
                   </c-rt:if>
                   ${pu:reqSet('pc', ac.campaign) }
                   <a class="btn-promo" href="javascript:openCampaign_${status1.index }_${status2.index }()">${ac.campaign.campaignName } </a>
             
                   <script>
                   <c-rt:set scope="request" var="campaignDetail">
              ${pu:replaceAll(pc.campaignDetail, '\'', '&#39;')}
              </c-rt:set>
              <c-rt:set scope="request" var="campaignDesc">
              ${pu:replaceAll(pc.campaignDesc, '\'', '&#39;')}
              </c-rt:set>
                        function openCampaign_${status1.index }_${status2.index }(){
                             var dialogId='dialog';
                             <%
                             String campaignDetail=(String)request.getAttribute("campaignDetail");
                             String campaignDesc=(String)request.getAttribute("campaignDesc");
                             campaignDetail=campaignDetail.replaceAll("\r\n", "").replaceAll("\r", "").replaceAll("\n", "");
                             campaignDesc=campaignDesc.replaceAll("\r\n", "").replaceAll("\r", "").replaceAll("\n", "");
                             request.setAttribute("campaignDetail", campaignDetail);
                             request.setAttribute("campaignDesc", campaignDesc);
                             %>
                             title='活动信息';
                             campaignTitle='${pu:replaceAll(pc.campaignName, '\'', '&#39;')}';
                             desc= '${campaignDesc}';
                             detail='${campaignDetail}';
                             startDate= '<fmt-rt:formatDate value="${pc.startDateTime}" pattern="yyyy/MM/dd HH:mm:ss"/>';
                             endDate= '<fmt-rt:formatDate value="${pc.endDateTime}" pattern="yyyy/MM/dd HH:mm:ss"/>';
                             url= '${pc.campaignUrl}';
                             width= 300;
                             height= 'auto';

                             var content=compositeCampaign(campaignTitle, desc, detail, startDate, endDate, url);
                             openDialog(title, content,width,height);
                             $( '#'+dialogId).dialog('option', 'position', 'top' );
                        }
                   </script>
                   </p><td/></tr></table>
                   </c-rt:forEach>

                   </c-rt:if>
               </c-rt:forEach>
               </c-rt:if>
                          </c-rt:forEach>
                        </td>
                        <td align="left" class="txt-price">￥ ${pu:rmb( op.totalPrice)}</td>
                      </tr>
                        </c-rt:if>
                        <c-rt:if test="${op.prodTp=='5'}">
                             <tr>
                                 <td colspan='5' align='left' class='table-in'>
                                      <table border='0'>
                                      <tr>
                                           <td width='430'><p>${op.prodName}</p></td>
                                           <td width='80'><span class='type-5'>满额购</span></td>
                                           <td width='100'>${op.prodSpecName}</td>
                                           <td width='70' class='txt-price'>￥ ${pu:rmb(op.amount)}</td>
                                           <input type='hidden' id='editAmount_x'  value='${op.amount}'/>
                                           <td width='50'>1</td>
                                      </tr>
                                      </table>
                                 </td>
                                 <td align='left' class='txt-price'>￥ ${pu:rmb( op.totalPrice)}</td>
                             </tr>
                        </c-rt:if>
                      </c-rt:forEach>
                        </tbody>
         </table>
         <input type="hidden" id="addCmpPd" name="addCmpPd" value="${addCmpPd}"/>
         <input type="hidden" id="addCmpPdId" name="addCmpPdId" value="${pu:split(addCmpPd, ',')[0] }"/> 
        <p class="total">本次订购共 <strong class="txt-rd">${cartOrders.productSum}</strong> 项商品，合计金额：<span>￥<input type="text" id="editTotalAmount" name="editTotalAmount" value=""  class="show-money txt-bk" readonly="readonly">元</span></p>
        <p class="total">＋运费：<span>￥<input type="text" id="editShipFare" name="editShipFare" value="0.0" class="show-money txt-bk" readonly="readonly">元</span></p>
        <p class="total">＋货到付款手续费：<span>￥<input type="text" id="codFee"  value="0.0" class="show-money txt-bk" readonly="readonly">元</span></p>
        <p class="total">－折抵优惠：<span>￥<input type="text" id="totalDiscount" name="totalDiscount" value="0.0" class="show-money txt-bk" readonly="readonly">元</span></p>
        <p class="total">－抵扣礼券：<span>￥<input type="text" id="editCoupon" name="editCoupon" value="0.0" class="show-money txt-bk" readonly="readonly">元</span></p>
        <p class="total">－折抵<strong class="txt-rd" id="editOffsetBonus">0</strong>积分：<span>￥<input type="text" id="editBonus" name="editBonus" value="0.0" class="show-money txt-bk" readonly="readonly">元</span></p>
        <div class="total-line">
             <p class="total"><strong>订单金额：</strong><span>￥<input type="text" id="finalTotalAmount"  name="finalTotalAmount" value="0" class="show-money txt-bk" readonly="readonly" >元</span></p>
             <p class="total">－礼品卡支付：<span>￥<input type="text" id="subGiftCard2" value="0.0" class="show-money txt-bk" readonly="readonly" >元</span></p>
             <p class="total">－帐户余额支付：<span>￥<input type="text" id="subVrtlBlnc2" value="0.0" class="show-money txt-bk" readonly="readonly" >元</span></p>
             <c-rt:if test="${'on' eq useCreditcardPeriod and not empty creditcard and chkAvailableDetails}">
             <p class="total">＋分期手续费：<span>￥<input type="text" id="editPeriodAmount" name="editPeriodAmount" value="0.0" class="show-money txt-bk" readonly="readonly" >元</span></p>
             </c-rt:if>
                   </div>
        <p class="total txt-m"><strong class="txt-rd">剩余应付金额：</strong>
        <strong class="txt-rd">￥<input type="text" id="finalMustPay" name="finalMustPay" class="show-money txt-L" readonly="readonly" size="14"/>元</strong>
        </p>
        <p class="total txt-m"><span class="txt-rd"><strong id="finalPeriodMoney2"></strong></span></p>
     </div>
      </div>
      <c-rt:if test="${needValidateNum}">
           <div class="incode">
               <div class="incotitle">验证码：</div>
               <div class="incowrap">
                    <input type="text" name="ccode" id="ccode" maxlength="6" class="ipt-w20" autocomplete="off">
                    <img id="iv" name="iv"> <a href="#chImg" id="chang_image">换张图</a></div>
                    <span style="display:block"><span id="codeTip" class="msg rn" style="display:none">请输入校验码</span></span>
               </div>
           </div>
      </c-rt:if>
        <!-- 訂單明細 -->
        <p class="btns"><a id="go_next" href="javascript:void(0);" class="btn-big-rd f-rt"><span>下一步</span></a>
        <c-rt:if test="${isBuyNow!='true'}">
        <a id="go_back" href="<%=ServerValue.getFrontContextPath()%>/shopping/cart.do" class="a-blue f-rt textlink" ><span>返回修改购物车</span></a>
        <input type="hidden" name="isBuyNow" id="isBuyNow" value="N_"/>
          </c-rt:if>
          <c-rt:if test="${isBuyNow=='true'}">
          <a id="go_back" href="<%=ServerValue.getFrontContextPath()%>/product/product.do?productId=<%=request.getParameter("itemNo")%>&z=<%=request.getParameter("categoryPath")%>" class="a-blue f-rt textlink" ><span>返回原商品页</span></a>
          <input type="hidden" name="isBuyNow" id="isBuyNow" value="Y_"/>
          <input type="hidden" name="editPeriod" id="editPeriod" value=""/>
          <input type="hidden" name="editPeriodFee" id="editPeriodFee" value=""/>
          </c-rt:if>
</p>
  </div>
  </div>
<input type="hidden" name="version" id="version" value=""/>
<input type="hidden" name="deliveryType" id="deliveryType" value="${deliveryType}"/>
<input type="hidden" name="ismobileVaild" id="ismobileVaild" value="${ismobileVaild}"/>
<div id="myAddBookDialog"></div>
</s:form>
<div id="myCouponDialog"></div>
<div id="divPayArrive"></div>
<div id="divPayPortage"></div>
<div id="showWeightDialog"></div>
<div id="showMessageDialog"></div>
<div id="specialMessageDialog"></div>
<DIV id="dialog"></div>
<div id="chkProdInvDialog" title="商品库存不足" class="alert-caution" style="display: none;">
     <p id="resultDiv"></p>
     <div align="center">
          <span style="text-align: center;">
              <a href="javascript:;" id="mainProdNotEnough" class="btn-mid">回商品页</a>
          </span>
     </div>
</div>
<div id="chkPinvyDialog" title="赠品库存不足" class="alert-caution" style="display: none;">
     <p id="resultDiv"></p>
     <div align="center">
          <span style="text-align: center;">
              <a href="javascript:;" id="presentNotEnough" class="btn-mid">回商品页</a>
          </span>
     </div>
</div>
<div id="mobileVaildDialog"></div>
